Imported Upstream version 0.7
[pysam.git] / pysam / ctabix.c
1 /* Generated by Cython 0.17.1 on Tue Nov 20 16:47:00 2012 */
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 #elif PY_VERSION_HEX < 0x02040000
8     #error Cython requires Python 2.4+.
9 #else
10 #include <stddef.h> /* For offsetof */
11 #ifndef offsetof
12 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
13 #endif
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 #ifndef DL_IMPORT
26   #define DL_IMPORT(t) t
27 #endif
28 #ifndef DL_EXPORT
29   #define DL_EXPORT(t) t
30 #endif
31 #ifndef PY_LONG_LONG
32   #define PY_LONG_LONG LONG_LONG
33 #endif
34 #ifndef Py_HUGE_VAL
35   #define Py_HUGE_VAL HUGE_VAL
36 #endif
37 #ifdef PYPY_VERSION
38 #define CYTHON_COMPILING_IN_PYPY 1
39 #define CYTHON_COMPILING_IN_CPYTHON 0
40 #else
41 #define CYTHON_COMPILING_IN_PYPY 0
42 #define CYTHON_COMPILING_IN_CPYTHON 1
43 #endif
44 #if PY_VERSION_HEX < 0x02050000
45   typedef int Py_ssize_t;
46   #define PY_SSIZE_T_MAX INT_MAX
47   #define PY_SSIZE_T_MIN INT_MIN
48   #define PY_FORMAT_SIZE_T ""
49   #define CYTHON_FORMAT_SSIZE_T ""
50   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
51   #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
52   #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
53                                 (PyErr_Format(PyExc_TypeError, \
54                                               "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
55                                  (PyObject*)0))
56   #define PyIndex_Check(o)     (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
57   #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
58   #define __PYX_BUILD_PY_SSIZE_T "i"
59 #else
60   #define __PYX_BUILD_PY_SSIZE_T "n"
61   #define CYTHON_FORMAT_SSIZE_T "z"
62 #endif
63 #if PY_VERSION_HEX < 0x02060000
64   #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
65   #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
66   #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
67   #define PyVarObject_HEAD_INIT(type, size) \
68           PyObject_HEAD_INIT(type) size,
69   #define PyType_Modified(t)
70   typedef struct {
71      void *buf;
72      PyObject *obj;
73      Py_ssize_t len;
74      Py_ssize_t itemsize;
75      int readonly;
76      int ndim;
77      char *format;
78      Py_ssize_t *shape;
79      Py_ssize_t *strides;
80      Py_ssize_t *suboffsets;
81      void *internal;
82   } Py_buffer;
83   #define PyBUF_SIMPLE 0
84   #define PyBUF_WRITABLE 0x0001
85   #define PyBUF_FORMAT 0x0004
86   #define PyBUF_ND 0x0008
87   #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
88   #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
89   #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
90   #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
91   #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
92   #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
93   #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
94   typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
95   typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
96 #endif
97 #if PY_MAJOR_VERSION < 3
98   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
99   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
100           PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
101 #else
102   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
103   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
104           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
105 #endif
106 #if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
107   #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
108 #endif
109 #if PY_MAJOR_VERSION >= 3
110   #define Py_TPFLAGS_CHECKTYPES 0
111   #define Py_TPFLAGS_HAVE_INDEX 0
112 #endif
113 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
114   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
115 #endif
116 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
117   #define CYTHON_PEP393_ENABLED 1
118   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
119                                               0 : _PyUnicode_Ready((PyObject *)(op)))
120   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
121   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
122   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
123 #else
124   #define CYTHON_PEP393_ENABLED 0
125   #define __Pyx_PyUnicode_READY(op)       (0)
126   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
127   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
128   #define __Pyx_PyUnicode_READ(k, d, i)   ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
129 #endif
130 #if PY_MAJOR_VERSION >= 3
131   #define PyBaseString_Type            PyUnicode_Type
132   #define PyStringObject               PyUnicodeObject
133   #define PyString_Type                PyUnicode_Type
134   #define PyString_Check               PyUnicode_Check
135   #define PyString_CheckExact          PyUnicode_CheckExact
136 #endif
137 #if PY_VERSION_HEX < 0x02060000
138   #define PyBytesObject                PyStringObject
139   #define PyBytes_Type                 PyString_Type
140   #define PyBytes_Check                PyString_Check
141   #define PyBytes_CheckExact           PyString_CheckExact
142   #define PyBytes_FromString           PyString_FromString
143   #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
144   #define PyBytes_FromFormat           PyString_FromFormat
145   #define PyBytes_DecodeEscape         PyString_DecodeEscape
146   #define PyBytes_AsString             PyString_AsString
147   #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
148   #define PyBytes_Size                 PyString_Size
149   #define PyBytes_AS_STRING            PyString_AS_STRING
150   #define PyBytes_GET_SIZE             PyString_GET_SIZE
151   #define PyBytes_Repr                 PyString_Repr
152   #define PyBytes_Concat               PyString_Concat
153   #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
154 #endif
155 #if PY_VERSION_HEX < 0x02060000
156   #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
157   #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
158 #endif
159 #ifndef PySet_CheckExact
160   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
161 #endif
162 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
163 #if PY_MAJOR_VERSION >= 3
164   #define PyIntObject                  PyLongObject
165   #define PyInt_Type                   PyLong_Type
166   #define PyInt_Check(op)              PyLong_Check(op)
167   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
168   #define PyInt_FromString             PyLong_FromString
169   #define PyInt_FromUnicode            PyLong_FromUnicode
170   #define PyInt_FromLong               PyLong_FromLong
171   #define PyInt_FromSize_t             PyLong_FromSize_t
172   #define PyInt_FromSsize_t            PyLong_FromSsize_t
173   #define PyInt_AsLong                 PyLong_AsLong
174   #define PyInt_AS_LONG                PyLong_AS_LONG
175   #define PyInt_AsSsize_t              PyLong_AsSsize_t
176   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
177   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
178 #endif
179 #if PY_MAJOR_VERSION >= 3
180   #define PyBoolObject                 PyLongObject
181 #endif
182 #if PY_VERSION_HEX < 0x03020000
183   typedef long Py_hash_t;
184   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
185   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
186 #else
187   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
188   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
189 #endif
190 #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
191   #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
192   #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
193   #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
194 #else
195   #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
196         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
197         (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
198             (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
199   #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
200         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
201         (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
202             (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
203   #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
204         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
205         (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
206             (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
207 #endif
208 #if PY_MAJOR_VERSION >= 3
209   #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
210 #endif
211 #if PY_VERSION_HEX < 0x02050000
212   #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
213   #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
214   #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
215 #else
216   #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
217   #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
218   #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
219 #endif
220 #if PY_VERSION_HEX < 0x02050000
221   #define __Pyx_NAMESTR(n) ((char *)(n))
222   #define __Pyx_DOCSTR(n)  ((char *)(n))
223 #else
224   #define __Pyx_NAMESTR(n) (n)
225   #define __Pyx_DOCSTR(n)  (n)
226 #endif
227
228
229 #if PY_MAJOR_VERSION >= 3
230   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
231   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
232 #else
233   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
234   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
235 #endif
236
237 #ifndef __PYX_EXTERN_C
238   #ifdef __cplusplus
239     #define __PYX_EXTERN_C extern "C"
240   #else
241     #define __PYX_EXTERN_C extern
242   #endif
243 #endif
244
245 #if defined(WIN32) || defined(MS_WINDOWS)
246 #define _USE_MATH_DEFINES
247 #endif
248 #include <math.h>
249 #define __PYX_HAVE__ctabix
250 #define __PYX_HAVE_API__ctabix
251 #include "string.h"
252 #include "stdlib.h"
253 #include "stdio.h"
254 #include "ctype.h"
255 #include "sys/types.h"
256 #include "sys/stat.h"
257 #include "fcntl.h"
258 #include "unistd.h"
259 #include "stdint.h"
260 #include "bgzf.h"
261 #include "tabix.h"
262 #include "pythread.h"
263 #ifdef _OPENMP
264 #include <omp.h>
265 #endif /* _OPENMP */
266
267 #ifdef PYREX_WITHOUT_ASSERTIONS
268 #define CYTHON_WITHOUT_ASSERTIONS
269 #endif
270
271
272 /* inline attribute */
273 #ifndef CYTHON_INLINE
274   #if defined(__GNUC__)
275     #define CYTHON_INLINE __inline__
276   #elif defined(_MSC_VER)
277     #define CYTHON_INLINE __inline
278   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
279     #define CYTHON_INLINE inline
280   #else
281     #define CYTHON_INLINE
282   #endif
283 #endif
284
285 /* unused attribute */
286 #ifndef CYTHON_UNUSED
287 # if defined(__GNUC__)
288 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
289 #     define CYTHON_UNUSED __attribute__ ((__unused__))
290 #   else
291 #     define CYTHON_UNUSED
292 #   endif
293 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
294 #   define CYTHON_UNUSED __attribute__ ((__unused__))
295 # else
296 #   define CYTHON_UNUSED
297 # endif
298 #endif
299
300 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*/
301
302
303 /* Type Conversion Predeclarations */
304
305 #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
306 #define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
307
308 #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
309 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
310 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
311 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
312
313 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
314 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
315 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
316
317 #if CYTHON_COMPILING_IN_CPYTHON
318 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
319 #else
320 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
321 #endif
322 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
323
324 #ifdef __GNUC__
325   /* Test for GCC > 2.95 */
326   #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
327     #define likely(x)   __builtin_expect(!!(x), 1)
328     #define unlikely(x) __builtin_expect(!!(x), 0)
329   #else /* __GNUC__ > 2 ... */
330     #define likely(x)   (x)
331     #define unlikely(x) (x)
332   #endif /* __GNUC__ > 2 ... */
333 #else /* __GNUC__ */
334   #define likely(x)   (x)
335   #define unlikely(x) (x)
336 #endif /* __GNUC__ */
337     
338 static PyObject *__pyx_m;
339 static PyObject *__pyx_b;
340 static PyObject *__pyx_empty_tuple;
341 static PyObject *__pyx_empty_bytes;
342 static int __pyx_lineno;
343 static int __pyx_clineno = 0;
344 static const char * __pyx_cfilenm= __FILE__;
345 static const char *__pyx_filename;
346
347
348 static const char *__pyx_f[] = {
349   "ctabix.pyx",
350   "TabProxies.pxd",
351   "type.pxd",
352   "bool.pxd",
353   "complex.pxd",
354 };
355
356 /*--- Type declarations ---*/
357 struct __pyx_obj_6ctabix_Parser;
358 struct __pyx_obj_6ctabix_asVCF;
359 struct __pyx_obj_10TabProxies_TupleProxy;
360 struct __pyx_obj_10TabProxies_NamedTupleProxy;
361 struct __pyx_obj_10TabProxies_BedProxy;
362 struct __pyx_obj_6ctabix_tabix_copy_iterator;
363 struct __pyx_obj_10TabProxies_VCFProxy;
364 struct __pyx_obj_10TabProxies_GTFProxy;
365 struct __pyx_obj_6ctabix_TabixIterator;
366 struct __pyx_obj_6ctabix_TabixIteratorParsed;
367 struct __pyx_obj_6ctabix_TabixHeaderIterator;
368 struct __pyx_obj_6ctabix_Tabixfile;
369 struct __pyx_obj_6ctabix_asGTF;
370 struct __pyx_obj_6ctabix_asBed;
371 struct __pyx_obj_6ctabix_tabix_inplace_iterator;
372 struct __pyx_obj_6ctabix_asTuple;
373
374 /* "ctabix.pxd":190
375  *     cdef tabix_t * tabixfile
376  * 
377  * cdef class Parser:             # <<<<<<<<<<<<<<
378  *      pass
379  * 
380  */
381 struct __pyx_obj_6ctabix_Parser {
382   PyObject_HEAD
383 };
384
385
386 /* "ctabix.pxd":202
387  *      pass
388  * 
389  * cdef class asVCF(Parser):             # <<<<<<<<<<<<<<
390  *      pass
391  * 
392  */
393 struct __pyx_obj_6ctabix_asVCF {
394   struct __pyx_obj_6ctabix_Parser __pyx_base;
395 };
396
397
398 /* "TabProxies.pxd":41
399  *   ctypedef int uint64_t
400  * 
401  * cdef class TupleProxy:             # <<<<<<<<<<<<<<
402  * 
403  *     cdef:
404  */
405 struct __pyx_obj_10TabProxies_TupleProxy {
406   PyObject_HEAD
407   struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtab;
408   char *data;
409   char **fields;
410   int nfields;
411   int index;
412   int nbytes;
413   int offset;
414   int is_modified;
415 };
416
417
418 /* "TabProxies.pxd":69
419  *     cdef char * getAttributes( self )
420  * 
421  * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
422  *     pass
423  * 
424  */
425 struct __pyx_obj_10TabProxies_NamedTupleProxy {
426   struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
427 };
428
429
430 /* "TabProxies.pxd":72
431  *     pass
432  * 
433  * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
434  * 
435  *     cdef:
436  */
437 struct __pyx_obj_10TabProxies_BedProxy {
438   struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
439   char *contig;
440   uint32_t start;
441   uint32_t end;
442   int bedfields;
443 };
444
445
446 /* "ctabix.pxd":218
447  *     cdef __cnext__(self)
448  * 
449  * ctypedef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
450  *     cdef FILE * infile
451  *     cdef Parser parser
452  */
453 struct __pyx_obj_6ctabix_tabix_copy_iterator {
454   PyObject_HEAD
455   struct __pyx_vtabstruct_6ctabix_tabix_copy_iterator *__pyx_vtab;
456   FILE *infile;
457   struct __pyx_obj_6ctabix_Parser *parser;
458 };
459
460
461 /* "TabProxies.pxd":83
462  *     cdef update( self, char * buffer, size_t nbytes )
463  * 
464  * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
465  * 
466  *     cdef:
467  */
468 struct __pyx_obj_10TabProxies_VCFProxy {
469   struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
470   char *contig;
471   uint32_t pos;
472 };
473
474
475 /* "TabProxies.pxd":60
476  *     cdef update( self, char * buffer, size_t nbytes )
477  * 
478  * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
479  * 
480  *     cdef:
481  */
482 struct __pyx_obj_10TabProxies_GTFProxy {
483   struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
484   char *_attributes;
485   int hasOwnAttributes;
486 };
487
488
489 /* "ctabix.pxd":182
490  *     cdef char * _filename
491  * 
492  * cdef class TabixIterator:             # <<<<<<<<<<<<<<
493  *     cdef ti_iter_t iterator
494  *     cdef tabix_t * tabixfile
495  */
496 struct __pyx_obj_6ctabix_TabixIterator {
497   PyObject_HEAD
498   ti_iter_t iterator;
499   tabix_t *tabixfile;
500 };
501
502
503 /* "ctabix.pxd":205
504  *      pass
505  * 
506  * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
507  *     cdef ti_iter_t iterator
508  *     cdef tabix_t * tabixfile
509  */
510 struct __pyx_obj_6ctabix_TabixIteratorParsed {
511   PyObject_HEAD
512   ti_iter_t iterator;
513   tabix_t *tabixfile;
514   struct __pyx_obj_6ctabix_Parser *parser;
515 };
516
517
518 /* "ctabix.pxd":186
519  *     cdef tabix_t * tabixfile
520  * 
521  * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
522  *     cdef ti_iter_t iterator
523  *     cdef tabix_t * tabixfile
524  */
525 struct __pyx_obj_6ctabix_TabixHeaderIterator {
526   PyObject_HEAD
527   ti_iter_t iterator;
528   tabix_t *tabixfile;
529 };
530
531
532 /* "ctabix.pxd":172
533  *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
534  * 
535  * cdef class Tabixfile:             # <<<<<<<<<<<<<<
536  * 
537  *     # pointer to tabixfile
538  */
539 struct __pyx_obj_6ctabix_Tabixfile {
540   PyObject_HEAD
541   tabix_t *tabixfile;
542   int isremote;
543   char *_filename;
544 };
545
546
547 /* "ctabix.pxd":196
548  *      pass
549  * 
550  * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
551  *      pass
552  * 
553  */
554 struct __pyx_obj_6ctabix_asGTF {
555   struct __pyx_obj_6ctabix_Parser __pyx_base;
556 };
557
558
559 /* "ctabix.pxd":199
560  *      pass
561  * 
562  * cdef class asBed(Parser):             # <<<<<<<<<<<<<<
563  *      pass
564  * 
565  */
566 struct __pyx_obj_6ctabix_asBed {
567   struct __pyx_obj_6ctabix_Parser __pyx_base;
568 };
569
570
571 /* "ctabix.pxd":210
572  *     cdef Parser parser
573  * 
574  * ctypedef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
575  *     cdef FILE * infile
576  *     cdef char * buffer
577  */
578 struct __pyx_obj_6ctabix_tabix_inplace_iterator {
579   PyObject_HEAD
580   struct __pyx_vtabstruct_6ctabix_tabix_inplace_iterator *__pyx_vtab;
581   FILE *infile;
582   char *buffer;
583   size_t size;
584   struct __pyx_obj_6ctabix_Parser *parser;
585 };
586
587
588 /* "ctabix.pxd":193
589  *      pass
590  * 
591  * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
592  *      pass
593  * 
594  */
595 struct __pyx_obj_6ctabix_asTuple {
596   struct __pyx_obj_6ctabix_Parser __pyx_base;
597 };
598
599
600
601 /* "ctabix.pyx":768
602  *         return self.__cnext__()
603  * 
604  * ctypedef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
605  *     '''iterate over ``infile``.
606  * 
607  */
608
609 struct __pyx_vtabstruct_6ctabix_tabix_copy_iterator {
610   PyObject *(*__pyx___cnext__)(struct __pyx_obj_6ctabix_tabix_copy_iterator *);
611 };
612 static struct __pyx_vtabstruct_6ctabix_tabix_copy_iterator *__pyx_vtabptr_6ctabix_tabix_copy_iterator;
613
614
615 /* "TabProxies.pxd":41
616  *   ctypedef int uint64_t
617  * 
618  * cdef class TupleProxy:             # <<<<<<<<<<<<<<
619  * 
620  *     cdef:
621  */
622
623 struct __pyx_vtabstruct_10TabProxies_TupleProxy {
624   int (*getMaxFields)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t);
625   PyObject *(*take)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
626   PyObject *(*present)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
627   PyObject *(*copy)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
628   PyObject *(*update)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
629 };
630 static struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtabptr_10TabProxies_TupleProxy;
631
632
633 /* "TabProxies.pxd":69
634  *     cdef char * getAttributes( self )
635  * 
636  * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
637  *     pass
638  * 
639  */
640
641 struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy {
642   struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
643 };
644 static struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
645
646
647 /* "TabProxies.pxd":83
648  *     cdef update( self, char * buffer, size_t nbytes )
649  * 
650  * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
651  * 
652  *     cdef:
653  */
654
655 struct __pyx_vtabstruct_10TabProxies_VCFProxy {
656   struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
657 };
658 static struct __pyx_vtabstruct_10TabProxies_VCFProxy *__pyx_vtabptr_10TabProxies_VCFProxy;
659
660
661 /* "TabProxies.pxd":60
662  *     cdef update( self, char * buffer, size_t nbytes )
663  * 
664  * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
665  * 
666  *     cdef:
667  */
668
669 struct __pyx_vtabstruct_10TabProxies_GTFProxy {
670   struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
671   char *(*getAttributes)(struct __pyx_obj_10TabProxies_GTFProxy *);
672 };
673 static struct __pyx_vtabstruct_10TabProxies_GTFProxy *__pyx_vtabptr_10TabProxies_GTFProxy;
674
675
676 /* "TabProxies.pxd":72
677  *     pass
678  * 
679  * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
680  * 
681  *     cdef:
682  */
683
684 struct __pyx_vtabstruct_10TabProxies_BedProxy {
685   struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
686 };
687 static struct __pyx_vtabstruct_10TabProxies_BedProxy *__pyx_vtabptr_10TabProxies_BedProxy;
688
689
690 /* "ctabix.pyx":706
691  * ## Iterators for parsing through unindexed files.
692  * #########################################################
693  * ctypedef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
694  *     '''iterate over ``infile``.
695  * 
696  */
697
698 struct __pyx_vtabstruct_6ctabix_tabix_inplace_iterator {
699   PyObject *(*__pyx___cnext__)(struct __pyx_obj_6ctabix_tabix_inplace_iterator *);
700 };
701 static struct __pyx_vtabstruct_6ctabix_tabix_inplace_iterator *__pyx_vtabptr_6ctabix_tabix_inplace_iterator;
702 #ifndef CYTHON_REFNANNY
703   #define CYTHON_REFNANNY 0
704 #endif
705 #if CYTHON_REFNANNY
706   typedef struct {
707     void (*INCREF)(void*, PyObject*, int);
708     void (*DECREF)(void*, PyObject*, int);
709     void (*GOTREF)(void*, PyObject*, int);
710     void (*GIVEREF)(void*, PyObject*, int);
711     void* (*SetupContext)(const char*, int, const char*);
712     void (*FinishContext)(void**);
713   } __Pyx_RefNannyAPIStruct;
714   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
715   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
716   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
717 #ifdef WITH_THREAD
718   #define __Pyx_RefNannySetupContext(name, acquire_gil) \
719           if (acquire_gil) { \
720               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
721               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
722               PyGILState_Release(__pyx_gilstate_save); \
723           } else { \
724               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
725           }
726 #else
727   #define __Pyx_RefNannySetupContext(name, acquire_gil) \
728           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
729 #endif
730   #define __Pyx_RefNannyFinishContext() \
731           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
732   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
733   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
734   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
735   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
736   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
737   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
738   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
739   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
740 #else
741   #define __Pyx_RefNannyDeclarations
742   #define __Pyx_RefNannySetupContext(name, acquire_gil)
743   #define __Pyx_RefNannyFinishContext()
744   #define __Pyx_INCREF(r) Py_INCREF(r)
745   #define __Pyx_DECREF(r) Py_DECREF(r)
746   #define __Pyx_GOTREF(r)
747   #define __Pyx_GIVEREF(r)
748   #define __Pyx_XINCREF(r) Py_XINCREF(r)
749   #define __Pyx_XDECREF(r) Py_XDECREF(r)
750   #define __Pyx_XGOTREF(r)
751   #define __Pyx_XGIVEREF(r)
752 #endif /* CYTHON_REFNANNY */
753 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
754 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
755
756 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
757
758 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
759          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
760          const char* encoding, const char* errors,
761          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
762
763 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
764 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
765
766 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
767
768 #include <string.h>
769
770 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
771
772 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
773     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
774     const char* function_name); /*proto*/
775
776 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
777     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
778
779 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
780     PyObject *r;
781     if (!j) return NULL;
782     r = PyObject_GetItem(o, j);
783     Py_DECREF(j);
784     return r;
785 }
786 #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
787                                                     __Pyx_GetItemInt_List_Fast(o, i) : \
788                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
789 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
790 #if CYTHON_COMPILING_IN_CPYTHON
791     if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
792         PyObject *r = PyList_GET_ITEM(o, i);
793         Py_INCREF(r);
794         return r;
795     }
796     else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
797         PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
798         Py_INCREF(r);
799         return r;
800     }
801     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
802 #else
803     return PySequence_GetItem(o, i);
804 #endif
805 }
806 #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
807                                                     __Pyx_GetItemInt_Tuple_Fast(o, i) : \
808                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
809 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
810 #if CYTHON_COMPILING_IN_CPYTHON
811     if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
812         PyObject *r = PyTuple_GET_ITEM(o, i);
813         Py_INCREF(r);
814         return r;
815     }
816     else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
817         PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
818         Py_INCREF(r);
819         return r;
820     }
821     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
822 #else
823     return PySequence_GetItem(o, i);
824 #endif
825 }
826 #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
827                                                     __Pyx_GetItemInt_Fast(o, i) : \
828                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
829 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
830 #if CYTHON_COMPILING_IN_CPYTHON
831     if (PyList_CheckExact(o)) {
832         Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
833         if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
834             PyObject *r = PyList_GET_ITEM(o, n);
835             Py_INCREF(r);
836             return r;
837         }
838     }
839     else if (PyTuple_CheckExact(o)) {
840         Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
841         if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
842             PyObject *r = PyTuple_GET_ITEM(o, n);
843             Py_INCREF(r);
844             return r;
845         }
846     } else {  /* inlined PySequence_GetItem() */
847         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
848         if (likely(m && m->sq_item)) {
849             if (unlikely(i < 0) && likely(m->sq_length)) {
850                 Py_ssize_t l = m->sq_length(o);
851                 if (unlikely(l < 0)) return NULL;
852                 i += l;
853             }
854             return m->sq_item(o, i);
855         }
856     }
857 #else
858     if (PySequence_Check(o)) {
859         return PySequence_GetItem(o, i);
860     }
861 #endif
862     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
863 }
864
865 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
866
867 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
868
869 static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/
870
871 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/
872
873 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
874     const char *name, int exact); /*proto*/
875
876 #if PY_MAJOR_VERSION >= 3
877 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
878     PyObject *value;
879     value = PyDict_GetItemWithError(d, key);
880     if (unlikely(!value)) {
881         if (!PyErr_Occurred())
882             PyErr_SetObject(PyExc_KeyError, key);
883         return NULL;
884     }
885     Py_INCREF(value);
886     return value;
887 }
888 #else
889     #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
890 #endif
891
892 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
893
894 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
895 static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
896
897 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
898
899 static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
900
901 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
902                                    PyObject *modname); /*proto*/
903
904 #define __Pyx_CyFunction_USED 1
905 #include <structmember.h>
906 #define __Pyx_CYFUNCTION_STATICMETHOD  0x01
907 #define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
908 #define __Pyx_CYFUNCTION_CCLASS        0x04
909 #define __Pyx_CyFunction_GetClosure(f) \
910     (((__pyx_CyFunctionObject *) (f))->func_closure)
911 #define __Pyx_CyFunction_GetClassObj(f) \
912     (((__pyx_CyFunctionObject *) (f))->func_classobj)
913 #define __Pyx_CyFunction_Defaults(type, f) \
914     ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
915 #define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
916     ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
917 typedef struct {
918     PyCFunctionObject func;
919     int flags;
920     PyObject *func_dict;
921     PyObject *func_weakreflist;
922     PyObject *func_name;
923     PyObject *func_doc;
924     PyObject *func_code;
925     PyObject *func_closure;
926     PyObject *func_classobj; /* No-args super() class cell */
927     void *defaults;
928     int defaults_pyobjects;
929     PyObject *defaults_tuple; /* Const defaults tuple */
930     PyObject *(*defaults_getter)(PyObject *);
931 } __pyx_CyFunctionObject;
932 static PyTypeObject *__pyx_CyFunctionType = 0;
933 #define __Pyx_CyFunction_NewEx(ml, flags, self, module, code) \
934     __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, self, module, code)
935 static PyObject *__Pyx_CyFunction_New(PyTypeObject *,
936                                       PyMethodDef *ml, int flags,
937                                       PyObject *self, PyObject *module,
938                                       PyObject* code);
939 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
940                                                          size_t size,
941                                                          int pyobjects);
942 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
943                                                             PyObject *tuple);
944 static int __Pyx_CyFunction_init(void);
945
946 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);
947
948 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
949
950 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
951
952 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
953
954 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
955
956 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
957
958 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
959
960 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
961
962 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
963
964 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
965
966 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
967
968 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
969
970 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
971
972 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
973
974 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
975
976 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
977
978 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
979
980 static int __Pyx_check_binary_version(void);
981
982 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
983
984 #if !defined(__Pyx_PyIdentifier_FromString)
985 #if PY_MAJOR_VERSION < 3
986   #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
987 #else
988   #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
989 #endif
990 #endif
991
992 static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
993
994 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/
995
996 static void* __Pyx_GetVtable(PyObject *dict); /*proto*/
997
998 typedef struct {
999     int code_line;
1000     PyCodeObject* code_object;
1001 } __Pyx_CodeObjectCacheEntry;
1002 struct __Pyx_CodeObjectCache {
1003     int count;
1004     int max_count;
1005     __Pyx_CodeObjectCacheEntry* entries;
1006 };
1007 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1008 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1009 static PyCodeObject *__pyx_find_code_object(int code_line);
1010 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1011
1012 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1013                                int py_line, const char *filename); /*proto*/
1014
1015 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
1016
1017
1018 /* Module declarations from 'TabProxies' */
1019 static PyTypeObject *__pyx_ptype_10TabProxies_TupleProxy = 0;
1020 static PyTypeObject *__pyx_ptype_10TabProxies_GTFProxy = 0;
1021 static PyTypeObject *__pyx_ptype_10TabProxies_NamedTupleProxy = 0;
1022 static PyTypeObject *__pyx_ptype_10TabProxies_BedProxy = 0;
1023 static PyTypeObject *__pyx_ptype_10TabProxies_VCFProxy = 0;
1024
1025 /* Module declarations from 'cpython.version' */
1026
1027 /* Module declarations from 'cpython.ref' */
1028
1029 /* Module declarations from 'cpython.exc' */
1030
1031 /* Module declarations from 'cpython.module' */
1032
1033 /* Module declarations from 'cpython.mem' */
1034
1035 /* Module declarations from 'cpython.tuple' */
1036
1037 /* Module declarations from 'cpython.list' */
1038
1039 /* Module declarations from 'libc.stdio' */
1040
1041 /* Module declarations from 'cpython.object' */
1042
1043 /* Module declarations from 'cpython.sequence' */
1044
1045 /* Module declarations from 'cpython.mapping' */
1046
1047 /* Module declarations from 'cpython.iterator' */
1048
1049 /* Module declarations from '__builtin__' */
1050
1051 /* Module declarations from 'cpython.type' */
1052 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1053
1054 /* Module declarations from 'cpython.number' */
1055
1056 /* Module declarations from 'cpython.int' */
1057
1058 /* Module declarations from '__builtin__' */
1059
1060 /* Module declarations from 'cpython.bool' */
1061 static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
1062
1063 /* Module declarations from 'cpython.long' */
1064
1065 /* Module declarations from 'cpython.float' */
1066
1067 /* Module declarations from '__builtin__' */
1068
1069 /* Module declarations from 'cpython.complex' */
1070 static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
1071
1072 /* Module declarations from 'cpython.string' */
1073
1074 /* Module declarations from 'cpython.unicode' */
1075
1076 /* Module declarations from 'cpython.dict' */
1077
1078 /* Module declarations from 'cpython.instance' */
1079
1080 /* Module declarations from 'cpython.function' */
1081
1082 /* Module declarations from 'cpython.method' */
1083
1084 /* Module declarations from 'cpython.weakref' */
1085
1086 /* Module declarations from 'cpython.getargs' */
1087
1088 /* Module declarations from 'cpython.pythread' */
1089
1090 /* Module declarations from 'cpython.pystate' */
1091
1092 /* Module declarations from 'cpython.cobject' */
1093
1094 /* Module declarations from 'cpython.oldbuffer' */
1095
1096 /* Module declarations from 'cpython.set' */
1097
1098 /* Module declarations from 'cpython.buffer' */
1099
1100 /* Module declarations from 'cpython.bytes' */
1101
1102 /* Module declarations from 'cpython.pycapsule' */
1103
1104 /* Module declarations from 'cpython' */
1105
1106 /* Module declarations from 'ctabix' */
1107 static PyTypeObject *__pyx_ptype_6ctabix_Tabixfile = 0;
1108 static PyTypeObject *__pyx_ptype_6ctabix_TabixIterator = 0;
1109 static PyTypeObject *__pyx_ptype_6ctabix_TabixHeaderIterator = 0;
1110 static PyTypeObject *__pyx_ptype_6ctabix_Parser = 0;
1111 static PyTypeObject *__pyx_ptype_6ctabix_asTuple = 0;
1112 static PyTypeObject *__pyx_ptype_6ctabix_asGTF = 0;
1113 static PyTypeObject *__pyx_ptype_6ctabix_asBed = 0;
1114 static PyTypeObject *__pyx_ptype_6ctabix_asVCF = 0;
1115 static PyTypeObject *__pyx_ptype_6ctabix_TabixIteratorParsed = 0;
1116 static PyTypeObject *__pyx_ptype_6ctabix_tabix_inplace_iterator = 0;
1117 static PyTypeObject *__pyx_ptype_6ctabix_tabix_copy_iterator = 0;
1118 static PyObject *__pyx_v_6ctabix__FILENAME_ENCODING = 0;
1119 static PyObject *__pyx_f_6ctabix__my_encodeFilename(PyObject *); /*proto*/
1120 static PyObject *__pyx_f_6ctabix__force_bytes(PyObject *); /*proto*/
1121 static PyObject *__pyx_f_6ctabix__charptr_to_str(char *); /*proto*/
1122 #define __Pyx_MODULE_NAME "ctabix"
1123 int __pyx_module_is_main_ctabix = 0;
1124
1125 /* Implementation of 'ctabix' */
1126 static PyObject *__pyx_builtin_TypeError;
1127 static PyObject *__pyx_builtin_NotImplementedError;
1128 static PyObject *__pyx_builtin_IOError;
1129 static PyObject *__pyx_builtin_ValueError;
1130 static PyObject *__pyx_builtin_StopIteration;
1131 static PyObject *__pyx_builtin_OSError;
1132 static PyObject *__pyx_builtin_ord;
1133 static PyObject *__pyx_builtin_KeyError;
1134 static PyObject *__pyx_builtin_MemoryError;
1135 static int __pyx_pf_6ctabix_9Tabixfile___cinit__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_mode, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
1136 static PyObject *__pyx_pf_6ctabix_9Tabixfile_2_isOpen(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self); /* proto */
1137 static PyObject *__pyx_pf_6ctabix_9Tabixfile_4_open(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_mode); /* proto */
1138 static PyObject *__pyx_pf_6ctabix_9Tabixfile_6_parseRegion(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_region); /* proto */
1139 static PyObject *__pyx_pf_6ctabix_9Tabixfile_8fetch(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_region, PyObject *__pyx_v_parser); /* proto */
1140 static PyObject *__pyx_pf_6ctabix_9Tabixfile_8filename___get__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self); /* proto */
1141 static PyObject *__pyx_pf_6ctabix_9Tabixfile_6header___get__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self); /* proto */
1142 static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self); /* proto */
1143 static PyObject *__pyx_pf_6ctabix_9Tabixfile_10close(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self); /* proto */
1144 static void __pyx_pf_6ctabix_9Tabixfile_12__dealloc__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self); /* proto */
1145 static int __pyx_pf_6ctabix_13TabixIterator___cinit__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self, struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile, int __pyx_v_tid, int __pyx_v_start, int __pyx_v_end); /* proto */
1146 static PyObject *__pyx_pf_6ctabix_13TabixIterator_2__iter__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self); /* proto */
1147 static PyObject *__pyx_pf_6ctabix_13TabixIterator_4__next__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self); /* proto */
1148 static void __pyx_pf_6ctabix_13TabixIterator_6__dealloc__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self); /* proto */
1149 static int __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self, struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile); /* proto */
1150 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator_2__iter__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self); /* proto */
1151 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator_4__next__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self); /* proto */
1152 static void __pyx_pf_6ctabix_19TabixHeaderIterator_6__dealloc__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self); /* proto */
1153 static PyObject *__pyx_pf_6ctabix_7asTuple___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asTuple *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len); /* proto */
1154 static PyObject *__pyx_pf_6ctabix_5asGTF___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asGTF *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len); /* proto */
1155 static PyObject *__pyx_pf_6ctabix_5asBed___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asBed *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len); /* proto */
1156 static PyObject *__pyx_pf_6ctabix_5asVCF___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asVCF *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len); /* proto */
1157 static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self, struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile, int __pyx_v_tid, int __pyx_v_start, int __pyx_v_end, struct __pyx_obj_6ctabix_Parser *__pyx_v_parser); /* proto */
1158 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed_2__iter__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self); /* proto */
1159 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed_4__next__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self); /* proto */
1160 static void __pyx_pf_6ctabix_19TabixIteratorParsed_6__dealloc__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self); /* proto */
1161 static PyObject *__pyx_pf_6ctabix_tabix_compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_in, PyObject *__pyx_v_filename_out, PyObject *__pyx_v_force); /* proto */
1162 static PyObject *__pyx_pf_6ctabix_2tabix_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_force, PyObject *__pyx_v_seq_col, PyObject *__pyx_v_start_col, PyObject *__pyx_v_end_col, PyObject *__pyx_v_preset, PyObject *__pyx_v_meta_char, PyObject *__pyx_v_zerobased); /* proto */
1163 static int __pyx_pf_6ctabix_22tabix_inplace_iterator___cinit__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self, PyObject *__pyx_v_infile, int __pyx_v_buffer_size); /* proto */
1164 static PyObject *__pyx_pf_6ctabix_22tabix_inplace_iterator_2__iter__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self); /* proto */
1165 static void __pyx_pf_6ctabix_22tabix_inplace_iterator_4__dealloc__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self); /* proto */
1166 static PyObject *__pyx_pf_6ctabix_22tabix_inplace_iterator_6__next__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self); /* proto */
1167 static int __pyx_pf_6ctabix_19tabix_copy_iterator___cinit__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self, PyObject *__pyx_v_infile, struct __pyx_obj_6ctabix_Parser *__pyx_v_parser); /* proto */
1168 static PyObject *__pyx_pf_6ctabix_19tabix_copy_iterator_2__iter__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self); /* proto */
1169 static PyObject *__pyx_pf_6ctabix_19tabix_copy_iterator_4__next__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self); /* proto */
1170 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_infile, PyObject *__pyx_v_parser); /* proto */
1171 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1172 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator_4__next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1173 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator_6next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1174 static PyObject *__pyx_pf_6ctabix_4tabix_iterator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_infile, PyObject *__pyx_v_parser); /* proto */
1175 static char __pyx_k_1[] = "Argument must be string or unicode.";
1176 static char __pyx_k_3[] = "Argument must be string, bytes or unicode.";
1177 static char __pyx_k_5[] = "invalid file opening mode `%s`";
1178 static char __pyx_k_6[] = ".tbi";
1179 static char __pyx_k_7[] = "http:";
1180 static char __pyx_k_9[] = "ftp:";
1181 static char __pyx_k_12[] = "writing to tabix files not implemented";
1182 static char __pyx_k_14[] = "file `%s` not found";
1183 static char __pyx_k_15[] = "index `%s` not found";
1184 static char __pyx_k_16[] = "could not open file `%s`";
1185 static char __pyx_k_17[] = "%s:%i-%i";
1186 static char __pyx_k_18[] = "invalid region `%s`";
1187 static char __pyx_k_19[] = "invalid region: start (%i) > end (%i)";
1188 static char __pyx_k_20[] = "start out of range (%i)";
1189 static char __pyx_k_21[] = "end out of range (%i)";
1190 static char __pyx_k_22[] = "I/O operation on closed file";
1191 static char __pyx_k_25[] = "malformatted query or wrong sequence name.\n";
1192 static char __pyx_k_27[] = "can't open header.\n";
1193 static char __pyx_k_31[] = "Filename '%s' already exists, use *force* to overwrite";
1194 static char __pyx_k_32[] = "could not open '%s' for writing";
1195 static char __pyx_k_34[] = "could not open '%s' for reading";
1196 static char __pyx_k_36[] = "writing failed";
1197 static char __pyx_k_40[] = "#";
1198 static char __pyx_k_42[] = "No such file '%s'";
1199 static char __pyx_k_43[] = ".gz";
1200 static char __pyx_k_45[] = "Filename '%s.tbi' already exists, use *force* to overwrite";
1201 static char __pyx_k_47[] = "unknown preset '%s', valid presets are '%s'";
1202 static char __pyx_k_48[] = ",";
1203 static char __pyx_k_49[] = "I/O operation on closed file.";
1204 static char __pyx_k_52[] = "incomplete line at %s";
1205 static char __pyx_k_56[] = "tabix_generic_iterator";
1206 static char __pyx_k_57[] = "filename associated with this object.";
1207 static char __pyx_k_58[] = "the file header.\n          \n        .. note::\n            The header is returned as an iterator over lines without the\n            newline character.\n        ";
1208 static char __pyx_k_59[] = "chromosome names";
1209 static char __pyx_k_60[] = "getfilesystemencoding";
1210 static char __pyx_k_63[] = "/ifs/devel/pysam/pysam/ctabix.pyx";
1211 static char __pyx_k_74[] = "iterate over ``infile``.\n    \n    Permits the use of file-like objects for example from the gzip module.\n    ";
1212 static char __pyx_k_77[] = "tabix_inplace_iterator";
1213 static char __pyx_k__b[] = "b";
1214 static char __pyx_k__c[] = "c";
1215 static char __pyx_k__r[] = "r";
1216 static char __pyx_k__s[] = "s";
1217 static char __pyx_k__w[] = "w";
1218 static char __pyx_k__fn[] = "fn";
1219 static char __pyx_k__fp[] = "fp";
1220 static char __pyx_k__io[] = "io";
1221 static char __pyx_k__os[] = "os";
1222 static char __pyx_k__bed[] = "bed";
1223 static char __pyx_k__cpy[] = "cpy";
1224 static char __pyx_k__end[] = "end";
1225 static char __pyx_k__gff[] = "gff";
1226 static char __pyx_k__len[] = "len";
1227 static char __pyx_k__ord[] = "ord";
1228 static char __pyx_k__sam[] = "sam";
1229 static char __pyx_k__sys[] = "sys";
1230 static char __pyx_k__tid[] = "tid";
1231 static char __pyx_k__vcf[] = "vcf";
1232 static char __pyx_k__conf[] = "conf";
1233 static char __pyx_k__gzip[] = "gzip";
1234 static char __pyx_k__join[] = "join";
1235 static char __pyx_k__line[] = "line";
1236 static char __pyx_k__mode[] = "mode";
1237 static char __pyx_k__next[] = "next";
1238 static char __pyx_k__path[] = "path";
1239 static char __pyx_k__self[] = "self";
1240 static char __pyx_k___open[] = "_open";
1241 static char __pyx_k__asBed[] = "asBed";
1242 static char __pyx_k__asGTF[] = "asGTF";
1243 static char __pyx_k__asVCF[] = "asVCF";
1244 static char __pyx_k__ascii[] = "ascii";
1245 static char __pyx_k__close[] = "close";
1246 static char __pyx_k__force[] = "force";
1247 static char __pyx_k__start[] = "start";
1248 static char __pyx_k__types[] = "types";
1249 static char __pyx_k__Parser[] = "Parser";
1250 static char __pyx_k__buffer[] = "buffer";
1251 static char __pyx_k__closed[] = "closed";
1252 static char __pyx_k__ctabix[] = "ctabix";
1253 static char __pyx_k__ctypes[] = "ctypes";
1254 static char __pyx_k__decode[] = "decode";
1255 static char __pyx_k__encode[] = "encode";
1256 static char __pyx_k__exists[] = "exists";
1257 static char __pyx_k__fd_src[] = "fd_src";
1258 static char __pyx_k__infile[] = "infile";
1259 static char __pyx_k__nbytes[] = "nbytes";
1260 static char __pyx_k__parser[] = "parser";
1261 static char __pyx_k__pileup[] = "pileup";
1262 static char __pyx_k__preset[] = "preset";
1263 static char __pyx_k__psltbl[] = "psltbl";
1264 static char __pyx_k__region[] = "region";
1265 static char __pyx_k__struct[] = "struct";
1266 static char __pyx_k__unlink[] = "unlink";
1267 static char __pyx_k__IOError[] = "IOError";
1268 static char __pyx_k__OSError[] = "OSError";
1269 static char __pyx_k__PYTHON3[] = "PYTHON3";
1270 static char __pyx_k____all__[] = "__all__";
1271 static char __pyx_k___isOpen[] = "_isOpen";
1272 static char __pyx_k__asTuple[] = "asTuple";
1273 static char __pyx_k__end_col[] = "end_col";
1274 static char __pyx_k__present[] = "present";
1275 static char __pyx_k__seq_col[] = "seq_col";
1276 static char __pyx_k__KeyError[] = "KeyError";
1277 static char __pyx_k__O_RDONLY[] = "O_RDONLY";
1278 static char __pyx_k____init__[] = "__init__";
1279 static char __pyx_k____iter__[] = "__iter__";
1280 static char __pyx_k____main__[] = "__main__";
1281 static char __pyx_k____next__[] = "__next__";
1282 static char __pyx_k____test__[] = "__test__";
1283 static char __pyx_k__endswith[] = "endswith";
1284 static char __pyx_k__filename[] = "filename";
1285 static char __pyx_k__readline[] = "readline";
1286 static char __pyx_k__tempfile[] = "tempfile";
1287 static char __pyx_k__Tabixfile[] = "Tabixfile";
1288 static char __pyx_k__TypeError[] = "TypeError";
1289 static char __pyx_k__conf_data[] = "conf_data";
1290 static char __pyx_k__itertools[] = "itertools";
1291 static char __pyx_k__meta_char[] = "meta_char";
1292 static char __pyx_k__reference[] = "reference";
1293 static char __pyx_k__start_col[] = "start_col";
1294 static char __pyx_k__tabixfile[] = "tabixfile";
1295 static char __pyx_k__zerobased[] = "zerobased";
1296 static char __pyx_k__ValueError[] = "ValueError";
1297 static char __pyx_k__startswith[] = "startswith";
1298 static char __pyx_k__MemoryError[] = "MemoryError";
1299 static char __pyx_k__WINDOW_SIZE[] = "WINDOW_SIZE";
1300 static char __pyx_k__buffer_size[] = "buffer_size";
1301 static char __pyx_k__filename_in[] = "filename_in";
1302 static char __pyx_k__preset2conf[] = "preset2conf";
1303 static char __pyx_k__tabix_index[] = "tabix_index";
1304 static char __pyx_k___parseRegion[] = "_parseRegion";
1305 static char __pyx_k__filename_out[] = "filename_out";
1306 static char __pyx_k__StopIteration[] = "StopIteration";
1307 static char __pyx_k__tabix_compress[] = "tabix_compress";
1308 static char __pyx_k__tabix_iterator[] = "tabix_iterator";
1309 static char __pyx_k__getdefaultencoding[] = "getdefaultencoding";
1310 static char __pyx_k__NotImplementedError[] = "NotImplementedError";
1311 static PyObject *__pyx_kp_u_1;
1312 static PyObject *__pyx_kp_s_12;
1313 static PyObject *__pyx_kp_s_14;
1314 static PyObject *__pyx_kp_s_15;
1315 static PyObject *__pyx_kp_s_16;
1316 static PyObject *__pyx_kp_s_17;
1317 static PyObject *__pyx_kp_s_18;
1318 static PyObject *__pyx_kp_s_19;
1319 static PyObject *__pyx_kp_s_20;
1320 static PyObject *__pyx_kp_s_21;
1321 static PyObject *__pyx_kp_s_22;
1322 static PyObject *__pyx_kp_s_25;
1323 static PyObject *__pyx_kp_s_27;
1324 static PyObject *__pyx_kp_u_3;
1325 static PyObject *__pyx_kp_s_31;
1326 static PyObject *__pyx_kp_s_32;
1327 static PyObject *__pyx_kp_s_34;
1328 static PyObject *__pyx_kp_s_36;
1329 static PyObject *__pyx_kp_s_40;
1330 static PyObject *__pyx_kp_s_42;
1331 static PyObject *__pyx_kp_s_43;
1332 static PyObject *__pyx_kp_s_45;
1333 static PyObject *__pyx_kp_s_47;
1334 static PyObject *__pyx_kp_s_48;
1335 static PyObject *__pyx_kp_s_49;
1336 static PyObject *__pyx_kp_s_5;
1337 static PyObject *__pyx_kp_s_52;
1338 static PyObject *__pyx_n_s_56;
1339 static PyObject *__pyx_kp_s_6;
1340 static PyObject *__pyx_n_s_60;
1341 static PyObject *__pyx_kp_s_63;
1342 static PyObject *__pyx_kp_s_7;
1343 static PyObject *__pyx_kp_s_74;
1344 static PyObject *__pyx_n_s_77;
1345 static PyObject *__pyx_kp_s_9;
1346 static PyObject *__pyx_n_s__IOError;
1347 static PyObject *__pyx_n_s__KeyError;
1348 static PyObject *__pyx_n_s__MemoryError;
1349 static PyObject *__pyx_n_s__NotImplementedError;
1350 static PyObject *__pyx_n_s__OSError;
1351 static PyObject *__pyx_n_s__O_RDONLY;
1352 static PyObject *__pyx_n_s__PYTHON3;
1353 static PyObject *__pyx_n_s__Parser;
1354 static PyObject *__pyx_n_s__StopIteration;
1355 static PyObject *__pyx_n_s__Tabixfile;
1356 static PyObject *__pyx_n_s__TypeError;
1357 static PyObject *__pyx_n_s__ValueError;
1358 static PyObject *__pyx_n_s__WINDOW_SIZE;
1359 static PyObject *__pyx_n_s____all__;
1360 static PyObject *__pyx_n_s____init__;
1361 static PyObject *__pyx_n_s____iter__;
1362 static PyObject *__pyx_n_s____main__;
1363 static PyObject *__pyx_n_s____next__;
1364 static PyObject *__pyx_n_s____test__;
1365 static PyObject *__pyx_n_s___isOpen;
1366 static PyObject *__pyx_n_s___open;
1367 static PyObject *__pyx_n_s___parseRegion;
1368 static PyObject *__pyx_n_s__asBed;
1369 static PyObject *__pyx_n_s__asGTF;
1370 static PyObject *__pyx_n_s__asTuple;
1371 static PyObject *__pyx_n_s__asVCF;
1372 static PyObject *__pyx_n_s__ascii;
1373 static PyObject *__pyx_n_s__b;
1374 static PyObject *__pyx_n_s__bed;
1375 static PyObject *__pyx_n_s__buffer;
1376 static PyObject *__pyx_n_s__buffer_size;
1377 static PyObject *__pyx_n_s__c;
1378 static PyObject *__pyx_n_s__close;
1379 static PyObject *__pyx_n_s__closed;
1380 static PyObject *__pyx_n_s__conf;
1381 static PyObject *__pyx_n_s__conf_data;
1382 static PyObject *__pyx_n_s__cpy;
1383 static PyObject *__pyx_n_s__ctabix;
1384 static PyObject *__pyx_n_s__ctypes;
1385 static PyObject *__pyx_n_s__decode;
1386 static PyObject *__pyx_n_s__encode;
1387 static PyObject *__pyx_n_s__end;
1388 static PyObject *__pyx_n_s__end_col;
1389 static PyObject *__pyx_n_s__endswith;
1390 static PyObject *__pyx_n_s__exists;
1391 static PyObject *__pyx_n_s__fd_src;
1392 static PyObject *__pyx_n_s__filename;
1393 static PyObject *__pyx_n_s__filename_in;
1394 static PyObject *__pyx_n_s__filename_out;
1395 static PyObject *__pyx_n_s__fn;
1396 static PyObject *__pyx_n_s__force;
1397 static PyObject *__pyx_n_s__fp;
1398 static PyObject *__pyx_n_s__getdefaultencoding;
1399 static PyObject *__pyx_n_s__gff;
1400 static PyObject *__pyx_n_s__gzip;
1401 static PyObject *__pyx_n_s__infile;
1402 static PyObject *__pyx_n_s__io;
1403 static PyObject *__pyx_n_s__itertools;
1404 static PyObject *__pyx_n_s__join;
1405 static PyObject *__pyx_n_s__len;
1406 static PyObject *__pyx_n_s__line;
1407 static PyObject *__pyx_n_s__meta_char;
1408 static PyObject *__pyx_n_s__mode;
1409 static PyObject *__pyx_n_s__nbytes;
1410 static PyObject *__pyx_n_s__next;
1411 static PyObject *__pyx_n_s__ord;
1412 static PyObject *__pyx_n_s__os;
1413 static PyObject *__pyx_n_s__parser;
1414 static PyObject *__pyx_n_s__path;
1415 static PyObject *__pyx_n_s__pileup;
1416 static PyObject *__pyx_n_s__present;
1417 static PyObject *__pyx_n_s__preset;
1418 static PyObject *__pyx_n_s__preset2conf;
1419 static PyObject *__pyx_n_s__psltbl;
1420 static PyObject *__pyx_n_s__r;
1421 static PyObject *__pyx_n_s__readline;
1422 static PyObject *__pyx_n_s__reference;
1423 static PyObject *__pyx_n_s__region;
1424 static PyObject *__pyx_n_s__s;
1425 static PyObject *__pyx_n_s__sam;
1426 static PyObject *__pyx_n_s__self;
1427 static PyObject *__pyx_n_s__seq_col;
1428 static PyObject *__pyx_n_s__start;
1429 static PyObject *__pyx_n_s__start_col;
1430 static PyObject *__pyx_n_s__startswith;
1431 static PyObject *__pyx_n_s__struct;
1432 static PyObject *__pyx_n_s__sys;
1433 static PyObject *__pyx_n_s__tabix_compress;
1434 static PyObject *__pyx_n_s__tabix_index;
1435 static PyObject *__pyx_n_s__tabix_iterator;
1436 static PyObject *__pyx_n_s__tabixfile;
1437 static PyObject *__pyx_n_s__tempfile;
1438 static PyObject *__pyx_n_s__tid;
1439 static PyObject *__pyx_n_s__types;
1440 static PyObject *__pyx_n_s__unlink;
1441 static PyObject *__pyx_n_s__vcf;
1442 static PyObject *__pyx_n_s__w;
1443 static PyObject *__pyx_n_s__zerobased;
1444 static PyObject *__pyx_int_0;
1445 static PyObject *__pyx_int_1;
1446 static PyObject *__pyx_int_2;
1447 static PyObject *__pyx_int_3;
1448 static PyObject *__pyx_int_4;
1449 static PyObject *__pyx_int_5;
1450 static PyObject *__pyx_int_neg_1;
1451 static PyObject *__pyx_int_15;
1452 static PyObject *__pyx_int_17;
1453 static PyObject *__pyx_int_18;
1454 static PyObject *__pyx_int_35;
1455 static PyObject *__pyx_int_65536;
1456 static PyObject *__pyx_k_30;
1457 static PyObject *__pyx_k_39;
1458 static PyObject *__pyx_k_41;
1459 static PyObject *__pyx_k_tuple_2;
1460 static PyObject *__pyx_k_tuple_4;
1461 static PyObject *__pyx_k_tuple_8;
1462 static PyObject *__pyx_k_tuple_10;
1463 static PyObject *__pyx_k_tuple_11;
1464 static PyObject *__pyx_k_tuple_13;
1465 static PyObject *__pyx_k_tuple_23;
1466 static PyObject *__pyx_k_tuple_24;
1467 static PyObject *__pyx_k_tuple_26;
1468 static PyObject *__pyx_k_tuple_28;
1469 static PyObject *__pyx_k_tuple_29;
1470 static PyObject *__pyx_k_tuple_33;
1471 static PyObject *__pyx_k_tuple_35;
1472 static PyObject *__pyx_k_tuple_37;
1473 static PyObject *__pyx_k_tuple_38;
1474 static PyObject *__pyx_k_tuple_44;
1475 static PyObject *__pyx_k_tuple_46;
1476 static PyObject *__pyx_k_tuple_50;
1477 static PyObject *__pyx_k_tuple_51;
1478 static PyObject *__pyx_k_tuple_53;
1479 static PyObject *__pyx_k_tuple_54;
1480 static PyObject *__pyx_k_tuple_55;
1481 static PyObject *__pyx_k_tuple_61;
1482 static PyObject *__pyx_k_tuple_64;
1483 static PyObject *__pyx_k_tuple_66;
1484 static PyObject *__pyx_k_tuple_68;
1485 static PyObject *__pyx_k_tuple_70;
1486 static PyObject *__pyx_k_tuple_72;
1487 static PyObject *__pyx_k_tuple_75;
1488 static PyObject *__pyx_k_codeobj_62;
1489 static PyObject *__pyx_k_codeobj_65;
1490 static PyObject *__pyx_k_codeobj_67;
1491 static PyObject *__pyx_k_codeobj_69;
1492 static PyObject *__pyx_k_codeobj_71;
1493 static PyObject *__pyx_k_codeobj_73;
1494 static PyObject *__pyx_k_codeobj_76;
1495
1496 /* "ctabix.pyx":19
1497  * from cpython.version cimport PY_MAJOR_VERSION
1498  * 
1499  * cdef from_string_and_size(char* s, size_t length):             # <<<<<<<<<<<<<<
1500  *     if PY_MAJOR_VERSION < 3:
1501  *         return s[:length]
1502  */
1503
1504 static PyObject *__pyx_f_6ctabix_from_string_and_size(char *__pyx_v_s, size_t __pyx_v_length) {
1505   PyObject *__pyx_r = NULL;
1506   __Pyx_RefNannyDeclarations
1507   int __pyx_t_1;
1508   PyObject *__pyx_t_2 = NULL;
1509   int __pyx_lineno = 0;
1510   const char *__pyx_filename = NULL;
1511   int __pyx_clineno = 0;
1512   __Pyx_RefNannySetupContext("from_string_and_size", 0);
1513
1514   /* "ctabix.pyx":20
1515  * 
1516  * cdef from_string_and_size(char* s, size_t length):
1517  *     if PY_MAJOR_VERSION < 3:             # <<<<<<<<<<<<<<
1518  *         return s[:length]
1519  *     else:
1520  */
1521   __pyx_t_1 = (PY_MAJOR_VERSION < 3);
1522   if (__pyx_t_1) {
1523
1524     /* "ctabix.pyx":21
1525  * cdef from_string_and_size(char* s, size_t length):
1526  *     if PY_MAJOR_VERSION < 3:
1527  *         return s[:length]             # <<<<<<<<<<<<<<
1528  *     else:
1529  *         return s[:length].decode("ascii")
1530  */
1531     __Pyx_XDECREF(__pyx_r);
1532     __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1533     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1534     __pyx_r = ((PyObject *)__pyx_t_2);
1535     __pyx_t_2 = 0;
1536     goto __pyx_L0;
1537     goto __pyx_L3;
1538   }
1539   /*else*/ {
1540
1541     /* "ctabix.pyx":23
1542  *         return s[:length]
1543  *     else:
1544  *         return s[:length].decode("ascii")             # <<<<<<<<<<<<<<
1545  * 
1546  * # filename encoding (copied from lxml.etree.pyx)
1547  */
1548     __Pyx_XDECREF(__pyx_r);
1549     __pyx_t_2 = ((PyObject *)__Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_length, NULL, NULL, PyUnicode_DecodeASCII)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1550     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1551     __pyx_r = ((PyObject *)__pyx_t_2);
1552     __pyx_t_2 = 0;
1553     goto __pyx_L0;
1554   }
1555   __pyx_L3:;
1556
1557   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1558   goto __pyx_L0;
1559   __pyx_L1_error:;
1560   __Pyx_XDECREF(__pyx_t_2);
1561   __Pyx_AddTraceback("ctabix.from_string_and_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
1562   __pyx_r = 0;
1563   __pyx_L0:;
1564   __Pyx_XGIVEREF(__pyx_r);
1565   __Pyx_RefNannyFinishContext();
1566   return __pyx_r;
1567 }
1568
1569 /* "ctabix.pyx":36
1570  * #_C_FILENAME_ENCODING = <char*>_FILENAME_ENCODING
1571  * 
1572  * cdef bytes _my_encodeFilename(object filename):             # <<<<<<<<<<<<<<
1573  *     u"""Make sure a filename is 8-bit encoded (or None).
1574  *     """
1575  */
1576
1577 static PyObject *__pyx_f_6ctabix__my_encodeFilename(PyObject *__pyx_v_filename) {
1578   PyObject *__pyx_r = NULL;
1579   __Pyx_RefNannyDeclarations
1580   int __pyx_t_1;
1581   PyObject *__pyx_t_2 = NULL;
1582   PyObject *__pyx_t_3 = NULL;
1583   PyObject *__pyx_t_4 = NULL;
1584   int __pyx_lineno = 0;
1585   const char *__pyx_filename = NULL;
1586   int __pyx_clineno = 0;
1587   __Pyx_RefNannySetupContext("_my_encodeFilename", 0);
1588
1589   /* "ctabix.pyx":39
1590  *     u"""Make sure a filename is 8-bit encoded (or None).
1591  *     """
1592  *     if filename is None:             # <<<<<<<<<<<<<<
1593  *         return None
1594  *     elif PyBytes_Check(filename):
1595  */
1596   __pyx_t_1 = (__pyx_v_filename == Py_None);
1597   if (__pyx_t_1) {
1598
1599     /* "ctabix.pyx":40
1600  *     """
1601  *     if filename is None:
1602  *         return None             # <<<<<<<<<<<<<<
1603  *     elif PyBytes_Check(filename):
1604  *         return filename
1605  */
1606     __Pyx_XDECREF(((PyObject *)__pyx_r));
1607     __Pyx_INCREF(Py_None);
1608     __pyx_r = ((PyObject*)Py_None);
1609     goto __pyx_L0;
1610     goto __pyx_L3;
1611   }
1612
1613   /* "ctabix.pyx":41
1614  *     if filename is None:
1615  *         return None
1616  *     elif PyBytes_Check(filename):             # <<<<<<<<<<<<<<
1617  *         return filename
1618  *     elif PyUnicode_Check(filename):
1619  */
1620   __pyx_t_1 = PyBytes_Check(__pyx_v_filename);
1621   if (__pyx_t_1) {
1622
1623     /* "ctabix.pyx":42
1624  *         return None
1625  *     elif PyBytes_Check(filename):
1626  *         return filename             # <<<<<<<<<<<<<<
1627  *     elif PyUnicode_Check(filename):
1628  *         return filename.encode(_FILENAME_ENCODING)
1629  */
1630     __Pyx_XDECREF(((PyObject *)__pyx_r));
1631     if (!(likely(PyBytes_CheckExact(__pyx_v_filename))||((__pyx_v_filename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_filename)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1632     __Pyx_INCREF(__pyx_v_filename);
1633     __pyx_r = ((PyObject*)__pyx_v_filename);
1634     goto __pyx_L0;
1635     goto __pyx_L3;
1636   }
1637
1638   /* "ctabix.pyx":43
1639  *     elif PyBytes_Check(filename):
1640  *         return filename
1641  *     elif PyUnicode_Check(filename):             # <<<<<<<<<<<<<<
1642  *         return filename.encode(_FILENAME_ENCODING)
1643  *     else:
1644  */
1645   __pyx_t_1 = PyUnicode_Check(__pyx_v_filename);
1646   if (__pyx_t_1) {
1647
1648     /* "ctabix.pyx":44
1649  *         return filename
1650  *     elif PyUnicode_Check(filename):
1651  *         return filename.encode(_FILENAME_ENCODING)             # <<<<<<<<<<<<<<
1652  *     else:
1653  *         raise TypeError, u"Argument must be string or unicode."
1654  */
1655     __Pyx_XDECREF(((PyObject *)__pyx_r));
1656     __pyx_t_2 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1657     __Pyx_GOTREF(__pyx_t_2);
1658     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1659     __Pyx_GOTREF(__pyx_t_3);
1660     __Pyx_INCREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
1661     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
1662     __Pyx_GIVEREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
1663     __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1664     __Pyx_GOTREF(__pyx_t_4);
1665     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1666     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
1667     if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1668     __pyx_r = ((PyObject*)__pyx_t_4);
1669     __pyx_t_4 = 0;
1670     goto __pyx_L0;
1671     goto __pyx_L3;
1672   }
1673   /*else*/ {
1674
1675     /* "ctabix.pyx":46
1676  *         return filename.encode(_FILENAME_ENCODING)
1677  *     else:
1678  *         raise TypeError, u"Argument must be string or unicode."             # <<<<<<<<<<<<<<
1679  * 
1680  * cdef bytes _force_bytes(object s):
1681  */
1682     __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_u_1), 0, 0);
1683     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1684   }
1685   __pyx_L3:;
1686
1687   __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
1688   goto __pyx_L0;
1689   __pyx_L1_error:;
1690   __Pyx_XDECREF(__pyx_t_2);
1691   __Pyx_XDECREF(__pyx_t_3);
1692   __Pyx_XDECREF(__pyx_t_4);
1693   __Pyx_AddTraceback("ctabix._my_encodeFilename", __pyx_clineno, __pyx_lineno, __pyx_filename);
1694   __pyx_r = 0;
1695   __pyx_L0:;
1696   __Pyx_XGIVEREF(__pyx_r);
1697   __Pyx_RefNannyFinishContext();
1698   return __pyx_r;
1699 }
1700
1701 /* "ctabix.pyx":48
1702  *         raise TypeError, u"Argument must be string or unicode."
1703  * 
1704  * cdef bytes _force_bytes(object s):             # <<<<<<<<<<<<<<
1705  *     u"""convert string or unicode object to bytes, assuming ascii encoding.
1706  *     """
1707  */
1708
1709 static PyObject *__pyx_f_6ctabix__force_bytes(PyObject *__pyx_v_s) {
1710   PyObject *__pyx_r = NULL;
1711   __Pyx_RefNannyDeclarations
1712   int __pyx_t_1;
1713   PyObject *__pyx_t_2 = NULL;
1714   PyObject *__pyx_t_3 = NULL;
1715   int __pyx_lineno = 0;
1716   const char *__pyx_filename = NULL;
1717   int __pyx_clineno = 0;
1718   __Pyx_RefNannySetupContext("_force_bytes", 0);
1719
1720   /* "ctabix.pyx":51
1721  *     u"""convert string or unicode object to bytes, assuming ascii encoding.
1722  *     """
1723  *     if PY_MAJOR_VERSION < 3:             # <<<<<<<<<<<<<<
1724  *         return s
1725  *     elif s is None:
1726  */
1727   __pyx_t_1 = (PY_MAJOR_VERSION < 3);
1728   if (__pyx_t_1) {
1729
1730     /* "ctabix.pyx":52
1731  *     """
1732  *     if PY_MAJOR_VERSION < 3:
1733  *         return s             # <<<<<<<<<<<<<<
1734  *     elif s is None:
1735  *         return None
1736  */
1737     __Pyx_XDECREF(((PyObject *)__pyx_r));
1738     if (!(likely(PyBytes_CheckExact(__pyx_v_s))||((__pyx_v_s) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_s)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1739     __Pyx_INCREF(__pyx_v_s);
1740     __pyx_r = ((PyObject*)__pyx_v_s);
1741     goto __pyx_L0;
1742     goto __pyx_L3;
1743   }
1744
1745   /* "ctabix.pyx":53
1746  *     if PY_MAJOR_VERSION < 3:
1747  *         return s
1748  *     elif s is None:             # <<<<<<<<<<<<<<
1749  *         return None
1750  *     elif PyBytes_Check(s):
1751  */
1752   __pyx_t_1 = (__pyx_v_s == Py_None);
1753   if (__pyx_t_1) {
1754
1755     /* "ctabix.pyx":54
1756  *         return s
1757  *     elif s is None:
1758  *         return None             # <<<<<<<<<<<<<<
1759  *     elif PyBytes_Check(s):
1760  *         return s
1761  */
1762     __Pyx_XDECREF(((PyObject *)__pyx_r));
1763     __Pyx_INCREF(Py_None);
1764     __pyx_r = ((PyObject*)Py_None);
1765     goto __pyx_L0;
1766     goto __pyx_L3;
1767   }
1768
1769   /* "ctabix.pyx":55
1770  *     elif s is None:
1771  *         return None
1772  *     elif PyBytes_Check(s):             # <<<<<<<<<<<<<<
1773  *         return s
1774  *     elif PyUnicode_Check(s):
1775  */
1776   __pyx_t_1 = PyBytes_Check(__pyx_v_s);
1777   if (__pyx_t_1) {
1778
1779     /* "ctabix.pyx":56
1780  *         return None
1781  *     elif PyBytes_Check(s):
1782  *         return s             # <<<<<<<<<<<<<<
1783  *     elif PyUnicode_Check(s):
1784  *         return s.encode('ascii')
1785  */
1786     __Pyx_XDECREF(((PyObject *)__pyx_r));
1787     if (!(likely(PyBytes_CheckExact(__pyx_v_s))||((__pyx_v_s) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_s)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1788     __Pyx_INCREF(__pyx_v_s);
1789     __pyx_r = ((PyObject*)__pyx_v_s);
1790     goto __pyx_L0;
1791     goto __pyx_L3;
1792   }
1793
1794   /* "ctabix.pyx":57
1795  *     elif PyBytes_Check(s):
1796  *         return s
1797  *     elif PyUnicode_Check(s):             # <<<<<<<<<<<<<<
1798  *         return s.encode('ascii')
1799  *     else:
1800  */
1801   __pyx_t_1 = PyUnicode_Check(__pyx_v_s);
1802   if (__pyx_t_1) {
1803
1804     /* "ctabix.pyx":58
1805  *         return s
1806  *     elif PyUnicode_Check(s):
1807  *         return s.encode('ascii')             # <<<<<<<<<<<<<<
1808  *     else:
1809  *         raise TypeError, u"Argument must be string, bytes or unicode."
1810  */
1811     __Pyx_XDECREF(((PyObject *)__pyx_r));
1812     __pyx_t_2 = PyObject_GetAttr(__pyx_v_s, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1813     __Pyx_GOTREF(__pyx_t_2);
1814     __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1815     __Pyx_GOTREF(__pyx_t_3);
1816     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1817     if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1818     __pyx_r = ((PyObject*)__pyx_t_3);
1819     __pyx_t_3 = 0;
1820     goto __pyx_L0;
1821     goto __pyx_L3;
1822   }
1823   /*else*/ {
1824
1825     /* "ctabix.pyx":60
1826  *         return s.encode('ascii')
1827  *     else:
1828  *         raise TypeError, u"Argument must be string, bytes or unicode."             # <<<<<<<<<<<<<<
1829  * 
1830  * cdef inline bytes _force_cmdline_bytes(object s):
1831  */
1832     __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_u_3), 0, 0);
1833     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1834   }
1835   __pyx_L3:;
1836
1837   __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
1838   goto __pyx_L0;
1839   __pyx_L1_error:;
1840   __Pyx_XDECREF(__pyx_t_2);
1841   __Pyx_XDECREF(__pyx_t_3);
1842   __Pyx_AddTraceback("ctabix._force_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
1843   __pyx_r = 0;
1844   __pyx_L0:;
1845   __Pyx_XGIVEREF(__pyx_r);
1846   __Pyx_RefNannyFinishContext();
1847   return __pyx_r;
1848 }
1849
1850 /* "ctabix.pyx":62
1851  *         raise TypeError, u"Argument must be string, bytes or unicode."
1852  * 
1853  * cdef inline bytes _force_cmdline_bytes(object s):             # <<<<<<<<<<<<<<
1854  *     return _force_bytes(s)
1855  * 
1856  */
1857
1858 static CYTHON_INLINE PyObject *__pyx_f_6ctabix__force_cmdline_bytes(PyObject *__pyx_v_s) {
1859   PyObject *__pyx_r = NULL;
1860   __Pyx_RefNannyDeclarations
1861   PyObject *__pyx_t_1 = NULL;
1862   int __pyx_lineno = 0;
1863   const char *__pyx_filename = NULL;
1864   int __pyx_clineno = 0;
1865   __Pyx_RefNannySetupContext("_force_cmdline_bytes", 0);
1866
1867   /* "ctabix.pyx":63
1868  * 
1869  * cdef inline bytes _force_cmdline_bytes(object s):
1870  *     return _force_bytes(s)             # <<<<<<<<<<<<<<
1871  * 
1872  * cdef _charptr_to_str(char* s):
1873  */
1874   __Pyx_XDECREF(((PyObject *)__pyx_r));
1875   __pyx_t_1 = ((PyObject *)__pyx_f_6ctabix__force_bytes(__pyx_v_s)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1876   __Pyx_GOTREF(__pyx_t_1);
1877   __pyx_r = ((PyObject*)__pyx_t_1);
1878   __pyx_t_1 = 0;
1879   goto __pyx_L0;
1880
1881   __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
1882   goto __pyx_L0;
1883   __pyx_L1_error:;
1884   __Pyx_XDECREF(__pyx_t_1);
1885   __Pyx_AddTraceback("ctabix._force_cmdline_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
1886   __pyx_r = 0;
1887   __pyx_L0:;
1888   __Pyx_XGIVEREF(__pyx_r);
1889   __Pyx_RefNannyFinishContext();
1890   return __pyx_r;
1891 }
1892
1893 /* "ctabix.pyx":65
1894  *     return _force_bytes(s)
1895  * 
1896  * cdef _charptr_to_str(char* s):             # <<<<<<<<<<<<<<
1897  *     if PY_MAJOR_VERSION < 3:
1898  *         return s
1899  */
1900
1901 static PyObject *__pyx_f_6ctabix__charptr_to_str(char *__pyx_v_s) {
1902   PyObject *__pyx_r = NULL;
1903   __Pyx_RefNannyDeclarations
1904   int __pyx_t_1;
1905   PyObject *__pyx_t_2 = NULL;
1906   int __pyx_lineno = 0;
1907   const char *__pyx_filename = NULL;
1908   int __pyx_clineno = 0;
1909   __Pyx_RefNannySetupContext("_charptr_to_str", 0);
1910
1911   /* "ctabix.pyx":66
1912  * 
1913  * cdef _charptr_to_str(char* s):
1914  *     if PY_MAJOR_VERSION < 3:             # <<<<<<<<<<<<<<
1915  *         return s
1916  *     else:
1917  */
1918   __pyx_t_1 = (PY_MAJOR_VERSION < 3);
1919   if (__pyx_t_1) {
1920
1921     /* "ctabix.pyx":67
1922  * cdef _charptr_to_str(char* s):
1923  *     if PY_MAJOR_VERSION < 3:
1924  *         return s             # <<<<<<<<<<<<<<
1925  *     else:
1926  *         return s.decode("ascii")
1927  */
1928     __Pyx_XDECREF(__pyx_r);
1929     __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1930     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1931     __pyx_r = ((PyObject *)__pyx_t_2);
1932     __pyx_t_2 = 0;
1933     goto __pyx_L0;
1934     goto __pyx_L3;
1935   }
1936   /*else*/ {
1937
1938     /* "ctabix.pyx":69
1939  *         return s
1940  *     else:
1941  *         return s.decode("ascii")             # <<<<<<<<<<<<<<
1942  * 
1943  * cdef _force_str(object s):
1944  */
1945     __Pyx_XDECREF(__pyx_r);
1946     __pyx_t_2 = ((PyObject *)__Pyx_decode_c_string(__pyx_v_s, 0, strlen(__pyx_v_s), NULL, NULL, PyUnicode_DecodeASCII)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1947     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1948     __pyx_r = ((PyObject *)__pyx_t_2);
1949     __pyx_t_2 = 0;
1950     goto __pyx_L0;
1951   }
1952   __pyx_L3:;
1953
1954   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1955   goto __pyx_L0;
1956   __pyx_L1_error:;
1957   __Pyx_XDECREF(__pyx_t_2);
1958   __Pyx_AddTraceback("ctabix._charptr_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
1959   __pyx_r = 0;
1960   __pyx_L0:;
1961   __Pyx_XGIVEREF(__pyx_r);
1962   __Pyx_RefNannyFinishContext();
1963   return __pyx_r;
1964 }
1965
1966 /* "ctabix.pyx":71
1967  *         return s.decode("ascii")
1968  * 
1969  * cdef _force_str(object s):             # <<<<<<<<<<<<<<
1970  *     """Return s converted to str type of current Python (bytes in Py2, unicode in Py3)"""
1971  *     if s is None:
1972  */
1973
1974 static PyObject *__pyx_f_6ctabix__force_str(PyObject *__pyx_v_s) {
1975   PyObject *__pyx_r = NULL;
1976   __Pyx_RefNannyDeclarations
1977   int __pyx_t_1;
1978   PyObject *__pyx_t_2 = NULL;
1979   PyObject *__pyx_t_3 = NULL;
1980   int __pyx_lineno = 0;
1981   const char *__pyx_filename = NULL;
1982   int __pyx_clineno = 0;
1983   __Pyx_RefNannySetupContext("_force_str", 0);
1984
1985   /* "ctabix.pyx":73
1986  * cdef _force_str(object s):
1987  *     """Return s converted to str type of current Python (bytes in Py2, unicode in Py3)"""
1988  *     if s is None:             # <<<<<<<<<<<<<<
1989  *         return None
1990  *     if PY_MAJOR_VERSION < 3:
1991  */
1992   __pyx_t_1 = (__pyx_v_s == Py_None);
1993   if (__pyx_t_1) {
1994
1995     /* "ctabix.pyx":74
1996  *     """Return s converted to str type of current Python (bytes in Py2, unicode in Py3)"""
1997  *     if s is None:
1998  *         return None             # <<<<<<<<<<<<<<
1999  *     if PY_MAJOR_VERSION < 3:
2000  *         return s
2001  */
2002     __Pyx_XDECREF(__pyx_r);
2003     __Pyx_INCREF(Py_None);
2004     __pyx_r = Py_None;
2005     goto __pyx_L0;
2006     goto __pyx_L3;
2007   }
2008   __pyx_L3:;
2009
2010   /* "ctabix.pyx":75
2011  *     if s is None:
2012  *         return None
2013  *     if PY_MAJOR_VERSION < 3:             # <<<<<<<<<<<<<<
2014  *         return s
2015  *     elif PyBytes_Check(s):
2016  */
2017   __pyx_t_1 = (PY_MAJOR_VERSION < 3);
2018   if (__pyx_t_1) {
2019
2020     /* "ctabix.pyx":76
2021  *         return None
2022  *     if PY_MAJOR_VERSION < 3:
2023  *         return s             # <<<<<<<<<<<<<<
2024  *     elif PyBytes_Check(s):
2025  *         return s.decode('ascii')
2026  */
2027     __Pyx_XDECREF(__pyx_r);
2028     __Pyx_INCREF(__pyx_v_s);
2029     __pyx_r = __pyx_v_s;
2030     goto __pyx_L0;
2031     goto __pyx_L4;
2032   }
2033
2034   /* "ctabix.pyx":77
2035  *     if PY_MAJOR_VERSION < 3:
2036  *         return s
2037  *     elif PyBytes_Check(s):             # <<<<<<<<<<<<<<
2038  *         return s.decode('ascii')
2039  *     else:
2040  */
2041   __pyx_t_1 = PyBytes_Check(__pyx_v_s);
2042   if (__pyx_t_1) {
2043
2044     /* "ctabix.pyx":78
2045  *         return s
2046  *     elif PyBytes_Check(s):
2047  *         return s.decode('ascii')             # <<<<<<<<<<<<<<
2048  *     else:
2049  *         # assume unicode
2050  */
2051     __Pyx_XDECREF(__pyx_r);
2052     __pyx_t_2 = PyObject_GetAttr(__pyx_v_s, __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2053     __Pyx_GOTREF(__pyx_t_2);
2054     __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2055     __Pyx_GOTREF(__pyx_t_3);
2056     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2057     __pyx_r = __pyx_t_3;
2058     __pyx_t_3 = 0;
2059     goto __pyx_L0;
2060     goto __pyx_L4;
2061   }
2062   /*else*/ {
2063
2064     /* "ctabix.pyx":81
2065  *     else:
2066  *         # assume unicode
2067  *         return s             # <<<<<<<<<<<<<<
2068  * 
2069  * 
2070  */
2071     __Pyx_XDECREF(__pyx_r);
2072     __Pyx_INCREF(__pyx_v_s);
2073     __pyx_r = __pyx_v_s;
2074     goto __pyx_L0;
2075   }
2076   __pyx_L4:;
2077
2078   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2079   goto __pyx_L0;
2080   __pyx_L1_error:;
2081   __Pyx_XDECREF(__pyx_t_2);
2082   __Pyx_XDECREF(__pyx_t_3);
2083   __Pyx_AddTraceback("ctabix._force_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
2084   __pyx_r = 0;
2085   __pyx_L0:;
2086   __Pyx_XGIVEREF(__pyx_r);
2087   __Pyx_RefNannyFinishContext();
2088   return __pyx_r;
2089 }
2090
2091 /* Python wrapper */
2092 static int __pyx_pw_6ctabix_9Tabixfile_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2093 static int __pyx_pw_6ctabix_9Tabixfile_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2094   PyObject *__pyx_v_filename = 0;
2095   PyObject *__pyx_v_mode = 0;
2096   PyObject *__pyx_v_args = 0;
2097   PyObject *__pyx_v_kwargs = 0;
2098   int __pyx_r;
2099   __Pyx_RefNannyDeclarations
2100   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
2101   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
2102   __Pyx_GOTREF(__pyx_v_kwargs);
2103   if (PyTuple_GET_SIZE(__pyx_args) > 2) {
2104     __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args));
2105     if (unlikely(!__pyx_v_args)) {
2106       __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
2107       __Pyx_RefNannyFinishContext();
2108       return -1;
2109     }
2110     __Pyx_GOTREF(__pyx_v_args);
2111   } else {
2112     __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2113   }
2114   {
2115     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,0};
2116     PyObject* values[2] = {0,0};
2117     values[1] = ((PyObject *)__pyx_n_s__r);
2118     if (unlikely(__pyx_kwds)) {
2119       Py_ssize_t kw_args;
2120       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2121       switch (pos_args) {
2122         default:
2123         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2124         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2125         case  0: break;
2126       }
2127       kw_args = PyDict_Size(__pyx_kwds);
2128       switch (pos_args) {
2129         case  0:
2130         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename)) != 0)) kw_args--;
2131         else goto __pyx_L5_argtuple_error;
2132         case  1:
2133         if (kw_args > 0) {
2134           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode);
2135           if (value) { values[1] = value; kw_args--; }
2136         }
2137       }
2138       if (unlikely(kw_args > 0)) {
2139         const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2;
2140         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2141       }
2142     } else {
2143       switch (PyTuple_GET_SIZE(__pyx_args)) {
2144         default:
2145         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2146         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2147         break;
2148         case  0:
2149         goto __pyx_L5_argtuple_error;
2150       }
2151     }
2152     __pyx_v_filename = values[0];
2153     __pyx_v_mode = values[1];
2154   }
2155   goto __pyx_L4_argument_unpacking_done;
2156   __pyx_L5_argtuple_error:;
2157   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2158   __pyx_L3_error:;
2159   __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
2160   __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
2161   __Pyx_AddTraceback("ctabix.Tabixfile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2162   __Pyx_RefNannyFinishContext();
2163   return -1;
2164   __pyx_L4_argument_unpacking_done:;
2165   __pyx_r = __pyx_pf_6ctabix_9Tabixfile___cinit__(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self), __pyx_v_filename, __pyx_v_mode, __pyx_v_args, __pyx_v_kwargs);
2166   __Pyx_XDECREF(__pyx_v_args);
2167   __Pyx_XDECREF(__pyx_v_kwargs);
2168   __Pyx_RefNannyFinishContext();
2169   return __pyx_r;
2170 }
2171
2172 /* "ctabix.pyx":90
2173  *     index (*filename* + ".tbi") will raise an exception.
2174  *     '''
2175  *     def __cinit__(self, filename, mode = 'r', *args, **kwargs ):             # <<<<<<<<<<<<<<
2176  *         self.tabixfile = NULL
2177  *         self._open( filename, mode, *args, **kwargs )
2178  */
2179
2180 static int __pyx_pf_6ctabix_9Tabixfile___cinit__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_mode, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
2181   int __pyx_r;
2182   __Pyx_RefNannyDeclarations
2183   PyObject *__pyx_t_1 = NULL;
2184   PyObject *__pyx_t_2 = NULL;
2185   PyObject *__pyx_t_3 = NULL;
2186   PyObject *__pyx_t_4 = NULL;
2187   int __pyx_lineno = 0;
2188   const char *__pyx_filename = NULL;
2189   int __pyx_clineno = 0;
2190   __Pyx_RefNannySetupContext("__cinit__", 0);
2191
2192   /* "ctabix.pyx":91
2193  *     '''
2194  *     def __cinit__(self, filename, mode = 'r', *args, **kwargs ):
2195  *         self.tabixfile = NULL             # <<<<<<<<<<<<<<
2196  *         self._open( filename, mode, *args, **kwargs )
2197  * 
2198  */
2199   __pyx_v_self->tabixfile = NULL;
2200
2201   /* "ctabix.pyx":92
2202  *     def __cinit__(self, filename, mode = 'r', *args, **kwargs ):
2203  *         self.tabixfile = NULL
2204  *         self._open( filename, mode, *args, **kwargs )             # <<<<<<<<<<<<<<
2205  * 
2206  *     def _isOpen( self ):
2207  */
2208   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2209   __Pyx_GOTREF(__pyx_t_1);
2210   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2211   __Pyx_GOTREF(__pyx_t_2);
2212   __Pyx_INCREF(__pyx_v_filename);
2213   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
2214   __Pyx_GIVEREF(__pyx_v_filename);
2215   __Pyx_INCREF(__pyx_v_mode);
2216   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_mode);
2217   __Pyx_GIVEREF(__pyx_v_mode);
2218   __pyx_t_3 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2219   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
2220   __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2221   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
2222   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2223   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2224   __pyx_t_3 = ((PyObject *)__pyx_v_kwargs);
2225   __Pyx_INCREF(__pyx_t_3);
2226   __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2227   __Pyx_GOTREF(__pyx_t_2);
2228   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2229   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
2230   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2231   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2232
2233   __pyx_r = 0;
2234   goto __pyx_L0;
2235   __pyx_L1_error:;
2236   __Pyx_XDECREF(__pyx_t_1);
2237   __Pyx_XDECREF(__pyx_t_2);
2238   __Pyx_XDECREF(__pyx_t_3);
2239   __Pyx_XDECREF(__pyx_t_4);
2240   __Pyx_AddTraceback("ctabix.Tabixfile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2241   __pyx_r = -1;
2242   __pyx_L0:;
2243   __Pyx_RefNannyFinishContext();
2244   return __pyx_r;
2245 }
2246
2247 /* Python wrapper */
2248 static PyObject *__pyx_pw_6ctabix_9Tabixfile_3_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2249 static char __pyx_doc_6ctabix_9Tabixfile_2_isOpen[] = "Tabixfile._isOpen(self)\nreturn true if samfile has been opened.";
2250 static PyObject *__pyx_pw_6ctabix_9Tabixfile_3_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2251   PyObject *__pyx_r = 0;
2252   __Pyx_RefNannyDeclarations
2253   __Pyx_RefNannySetupContext("_isOpen (wrapper)", 0);
2254   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_2_isOpen(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self));
2255   __Pyx_RefNannyFinishContext();
2256   return __pyx_r;
2257 }
2258
2259 /* "ctabix.pyx":94
2260  *         self._open( filename, mode, *args, **kwargs )
2261  * 
2262  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
2263  *         '''return true if samfile has been opened.'''
2264  *         return self.tabixfile != NULL
2265  */
2266
2267 static PyObject *__pyx_pf_6ctabix_9Tabixfile_2_isOpen(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self) {
2268   PyObject *__pyx_r = NULL;
2269   __Pyx_RefNannyDeclarations
2270   PyObject *__pyx_t_1 = NULL;
2271   int __pyx_lineno = 0;
2272   const char *__pyx_filename = NULL;
2273   int __pyx_clineno = 0;
2274   __Pyx_RefNannySetupContext("_isOpen", 0);
2275
2276   /* "ctabix.pyx":96
2277  *     def _isOpen( self ):
2278  *         '''return true if samfile has been opened.'''
2279  *         return self.tabixfile != NULL             # <<<<<<<<<<<<<<
2280  * 
2281  *     def _open( self,
2282  */
2283   __Pyx_XDECREF(__pyx_r);
2284   __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->tabixfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2285   __Pyx_GOTREF(__pyx_t_1);
2286   __pyx_r = __pyx_t_1;
2287   __pyx_t_1 = 0;
2288   goto __pyx_L0;
2289
2290   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2291   goto __pyx_L0;
2292   __pyx_L1_error:;
2293   __Pyx_XDECREF(__pyx_t_1);
2294   __Pyx_AddTraceback("ctabix.Tabixfile._isOpen", __pyx_clineno, __pyx_lineno, __pyx_filename);
2295   __pyx_r = NULL;
2296   __pyx_L0:;
2297   __Pyx_XGIVEREF(__pyx_r);
2298   __Pyx_RefNannyFinishContext();
2299   return __pyx_r;
2300 }
2301
2302 /* Python wrapper */
2303 static PyObject *__pyx_pw_6ctabix_9Tabixfile_5_open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2304 static char __pyx_doc_6ctabix_9Tabixfile_4_open[] = "Tabixfile._open(self, filename, mode='r')\nopen a :term:`tabix file` for reading.\n        ";
2305 static PyObject *__pyx_pw_6ctabix_9Tabixfile_5_open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2306   PyObject *__pyx_v_filename = 0;
2307   PyObject *__pyx_v_mode = 0;
2308   PyObject *__pyx_r = 0;
2309   __Pyx_RefNannyDeclarations
2310   __Pyx_RefNannySetupContext("_open (wrapper)", 0);
2311   {
2312     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,0};
2313     PyObject* values[2] = {0,0};
2314     values[1] = ((PyObject *)__pyx_n_s__r);
2315     if (unlikely(__pyx_kwds)) {
2316       Py_ssize_t kw_args;
2317       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2318       switch (pos_args) {
2319         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2320         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2321         case  0: break;
2322         default: goto __pyx_L5_argtuple_error;
2323       }
2324       kw_args = PyDict_Size(__pyx_kwds);
2325       switch (pos_args) {
2326         case  0:
2327         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename)) != 0)) kw_args--;
2328         else goto __pyx_L5_argtuple_error;
2329         case  1:
2330         if (kw_args > 0) {
2331           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode);
2332           if (value) { values[1] = value; kw_args--; }
2333         }
2334       }
2335       if (unlikely(kw_args > 0)) {
2336         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2337       }
2338     } else {
2339       switch (PyTuple_GET_SIZE(__pyx_args)) {
2340         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2341         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2342         break;
2343         default: goto __pyx_L5_argtuple_error;
2344       }
2345     }
2346     __pyx_v_filename = values[0];
2347     __pyx_v_mode = values[1];
2348   }
2349   goto __pyx_L4_argument_unpacking_done;
2350   __pyx_L5_argtuple_error:;
2351   __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2352   __pyx_L3_error:;
2353   __Pyx_AddTraceback("ctabix.Tabixfile._open", __pyx_clineno, __pyx_lineno, __pyx_filename);
2354   __Pyx_RefNannyFinishContext();
2355   return NULL;
2356   __pyx_L4_argument_unpacking_done:;
2357   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_4_open(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self), __pyx_v_filename, __pyx_v_mode);
2358   __Pyx_RefNannyFinishContext();
2359   return __pyx_r;
2360 }
2361
2362 /* "ctabix.pyx":98
2363  *         return self.tabixfile != NULL
2364  * 
2365  *     def _open( self,             # <<<<<<<<<<<<<<
2366  *                filename,
2367  *                mode ='r',
2368  */
2369
2370 static PyObject *__pyx_pf_6ctabix_9Tabixfile_4_open(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_mode) {
2371   PyObject *__pyx_v_filename_index = NULL;
2372   CYTHON_UNUSED PyObject *__pyx_v_bmode = 0;
2373   PyObject *__pyx_r = NULL;
2374   __Pyx_RefNannyDeclarations
2375   PyObject *__pyx_t_1 = NULL;
2376   PyObject *__pyx_t_2 = NULL;
2377   int __pyx_t_3;
2378   PyObject *__pyx_t_4 = NULL;
2379   int __pyx_t_5;
2380   char *__pyx_t_6;
2381   int __pyx_t_7;
2382   char *__pyx_t_8;
2383   int __pyx_lineno = 0;
2384   const char *__pyx_filename = NULL;
2385   int __pyx_clineno = 0;
2386   __Pyx_RefNannySetupContext("_open", 0);
2387   __Pyx_INCREF(__pyx_v_filename);
2388
2389   /* "ctabix.pyx":105
2390  *         '''
2391  * 
2392  *         assert mode in ( "r",), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
2393  * 
2394  *         # close a previously opened file
2395  */
2396   #ifndef CYTHON_WITHOUT_ASSERTIONS
2397   __Pyx_INCREF(__pyx_v_mode);
2398   __pyx_t_1 = __pyx_v_mode;
2399   __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2400   __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 = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2401   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2402   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2403   if (unlikely(!((int)__pyx_t_3))) {
2404     __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2405     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
2406     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_1));
2407     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
2408     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2409   }
2410   #endif
2411
2412   /* "ctabix.pyx":108
2413  * 
2414  *         # close a previously opened file
2415  *         if self.tabixfile != NULL: self.close()             # <<<<<<<<<<<<<<
2416  *         self.tabixfile = NULL
2417  * 
2418  */
2419   __pyx_t_3 = (__pyx_v_self->tabixfile != NULL);
2420   if (__pyx_t_3) {
2421     __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2422     __Pyx_GOTREF(__pyx_t_1);
2423     __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 = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2424     __Pyx_GOTREF(__pyx_t_2);
2425     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2426     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2427     goto __pyx_L3;
2428   }
2429   __pyx_L3:;
2430
2431   /* "ctabix.pyx":109
2432  *         # close a previously opened file
2433  *         if self.tabixfile != NULL: self.close()
2434  *         self.tabixfile = NULL             # <<<<<<<<<<<<<<
2435  * 
2436  *         filename_index = filename + ".tbi"
2437  */
2438   __pyx_v_self->tabixfile = NULL;
2439
2440   /* "ctabix.pyx":111
2441  *         self.tabixfile = NULL
2442  * 
2443  *         filename_index = filename + ".tbi"             # <<<<<<<<<<<<<<
2444  *         self.isremote = filename.startswith( "http:") or filename.startswith( "ftp:" )
2445  * 
2446  */
2447   __pyx_t_2 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2448   __Pyx_GOTREF(__pyx_t_2);
2449   __pyx_v_filename_index = __pyx_t_2;
2450   __pyx_t_2 = 0;
2451
2452   /* "ctabix.pyx":112
2453  * 
2454  *         filename_index = filename + ".tbi"
2455  *         self.isremote = filename.startswith( "http:") or filename.startswith( "ftp:" )             # <<<<<<<<<<<<<<
2456  * 
2457  *         # encode all the strings
2458  */
2459   __pyx_t_2 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2460   __Pyx_GOTREF(__pyx_t_2);
2461   __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2462   __Pyx_GOTREF(__pyx_t_1);
2463   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2464   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2465   if (!__pyx_t_3) {
2466     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2467     __pyx_t_2 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2468     __Pyx_GOTREF(__pyx_t_2);
2469     __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2470     __Pyx_GOTREF(__pyx_t_4);
2471     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2472     __pyx_t_2 = __pyx_t_4;
2473     __pyx_t_4 = 0;
2474   } else {
2475     __pyx_t_2 = __pyx_t_1;
2476     __pyx_t_1 = 0;
2477   }
2478   __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2479   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2480   __pyx_v_self->isremote = __pyx_t_5;
2481
2482   /* "ctabix.pyx":115
2483  * 
2484  *         # encode all the strings
2485  *         filename = _my_encodeFilename(filename)             # <<<<<<<<<<<<<<
2486  *         filename_index = _my_encodeFilename(filename_index)
2487  *         cdef bytes bmode = mode.encode('ascii')
2488  */
2489   __pyx_t_2 = ((PyObject *)__pyx_f_6ctabix__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2490   __Pyx_GOTREF(__pyx_t_2);
2491   __Pyx_DECREF(__pyx_v_filename);
2492   __pyx_v_filename = __pyx_t_2;
2493   __pyx_t_2 = 0;
2494
2495   /* "ctabix.pyx":116
2496  *         # encode all the strings
2497  *         filename = _my_encodeFilename(filename)
2498  *         filename_index = _my_encodeFilename(filename_index)             # <<<<<<<<<<<<<<
2499  *         cdef bytes bmode = mode.encode('ascii')
2500  * 
2501  */
2502   __pyx_t_2 = ((PyObject *)__pyx_f_6ctabix__my_encodeFilename(__pyx_v_filename_index)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2503   __Pyx_GOTREF(__pyx_t_2);
2504   __Pyx_DECREF(__pyx_v_filename_index);
2505   __pyx_v_filename_index = __pyx_t_2;
2506   __pyx_t_2 = 0;
2507
2508   /* "ctabix.pyx":117
2509  *         filename = _my_encodeFilename(filename)
2510  *         filename_index = _my_encodeFilename(filename_index)
2511  *         cdef bytes bmode = mode.encode('ascii')             # <<<<<<<<<<<<<<
2512  * 
2513  *         if self._filename != NULL: free(self._filename )
2514  */
2515   __pyx_t_2 = PyObject_GetAttr(__pyx_v_mode, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2516   __Pyx_GOTREF(__pyx_t_2);
2517   __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2518   __Pyx_GOTREF(__pyx_t_1);
2519   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2520   if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2521   __pyx_v_bmode = ((PyObject*)__pyx_t_1);
2522   __pyx_t_1 = 0;
2523
2524   /* "ctabix.pyx":119
2525  *         cdef bytes bmode = mode.encode('ascii')
2526  * 
2527  *         if self._filename != NULL: free(self._filename )             # <<<<<<<<<<<<<<
2528  * 
2529  *         self._filename = strdup(filename)
2530  */
2531   __pyx_t_3 = (__pyx_v_self->_filename != NULL);
2532   if (__pyx_t_3) {
2533     free(__pyx_v_self->_filename);
2534     goto __pyx_L4;
2535   }
2536   __pyx_L4:;
2537
2538   /* "ctabix.pyx":121
2539  *         if self._filename != NULL: free(self._filename )
2540  * 
2541  *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
2542  * 
2543  *         if mode[0] == 'w':
2544  */
2545   __pyx_t_6 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2546   __pyx_v_self->_filename = strdup(__pyx_t_6);
2547
2548   /* "ctabix.pyx":123
2549  *         self._filename = strdup(filename)
2550  * 
2551  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
2552  *             # open file for writing
2553  *             raise NotImplementedError("writing to tabix files not implemented" )
2554  */
2555   __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2556   __Pyx_GOTREF(__pyx_t_1);
2557   __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__w), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2558   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2559   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2560   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2561   if (__pyx_t_3) {
2562
2563     /* "ctabix.pyx":125
2564  *         if mode[0] == 'w':
2565  *             # open file for writing
2566  *             raise NotImplementedError("writing to tabix files not implemented" )             # <<<<<<<<<<<<<<
2567  * 
2568  *         elif mode[0] == "r":
2569  */
2570     __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2571     __Pyx_GOTREF(__pyx_t_2);
2572     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2573     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2574     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2575     goto __pyx_L5;
2576   }
2577
2578   /* "ctabix.pyx":127
2579  *             raise NotImplementedError("writing to tabix files not implemented" )
2580  * 
2581  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
2582  *             # open file for reading
2583  * 
2584  */
2585   __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2586   __Pyx_GOTREF(__pyx_t_2);
2587   __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2588   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2589   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2590   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2591   if (__pyx_t_3) {
2592
2593     /* "ctabix.pyx":130
2594  *             # open file for reading
2595  * 
2596  *             if not self.isremote:             # <<<<<<<<<<<<<<
2597  *                 if not os.path.exists( filename ):
2598  *                     raise IOError( "file `%s` not found" % filename)
2599  */
2600     __pyx_t_3 = (!__pyx_v_self->isremote);
2601     if (__pyx_t_3) {
2602
2603       /* "ctabix.pyx":131
2604  * 
2605  *             if not self.isremote:
2606  *                 if not os.path.exists( filename ):             # <<<<<<<<<<<<<<
2607  *                     raise IOError( "file `%s` not found" % filename)
2608  * 
2609  */
2610       __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2611       __Pyx_GOTREF(__pyx_t_1);
2612       __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2613       __Pyx_GOTREF(__pyx_t_2);
2614       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2615       __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2616       __Pyx_GOTREF(__pyx_t_1);
2617       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2618       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2619       __Pyx_GOTREF(__pyx_t_2);
2620       __Pyx_INCREF(__pyx_v_filename);
2621       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
2622       __Pyx_GIVEREF(__pyx_v_filename);
2623       __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2624       __Pyx_GOTREF(__pyx_t_4);
2625       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2626       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2627       __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2628       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2629       __pyx_t_7 = (!__pyx_t_3);
2630       if (__pyx_t_7) {
2631
2632         /* "ctabix.pyx":132
2633  *             if not self.isremote:
2634  *                 if not os.path.exists( filename ):
2635  *                     raise IOError( "file `%s` not found" % filename)             # <<<<<<<<<<<<<<
2636  * 
2637  *                 if not os.path.exists( filename_index ):
2638  */
2639         __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_v_filename); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2640         __Pyx_GOTREF(((PyObject *)__pyx_t_4));
2641         __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2642         __Pyx_GOTREF(__pyx_t_2);
2643         PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
2644         __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
2645         __pyx_t_4 = 0;
2646         __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 = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2647         __Pyx_GOTREF(__pyx_t_4);
2648         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2649         __Pyx_Raise(__pyx_t_4, 0, 0, 0);
2650         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2651         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2652         goto __pyx_L7;
2653       }
2654       __pyx_L7:;
2655
2656       /* "ctabix.pyx":134
2657  *                     raise IOError( "file `%s` not found" % filename)
2658  * 
2659  *                 if not os.path.exists( filename_index ):             # <<<<<<<<<<<<<<
2660  *                     raise IOError( "index `%s` not found" % filename_index)
2661  * 
2662  */
2663       __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2664       __Pyx_GOTREF(__pyx_t_4);
2665       __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2666       __Pyx_GOTREF(__pyx_t_2);
2667       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2668       __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2669       __Pyx_GOTREF(__pyx_t_4);
2670       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2671       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2672       __Pyx_GOTREF(__pyx_t_2);
2673       __Pyx_INCREF(__pyx_v_filename_index);
2674       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename_index);
2675       __Pyx_GIVEREF(__pyx_v_filename_index);
2676       __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 = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2677       __Pyx_GOTREF(__pyx_t_1);
2678       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2679       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2680       __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2681       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2682       __pyx_t_3 = (!__pyx_t_7);
2683       if (__pyx_t_3) {
2684
2685         /* "ctabix.pyx":135
2686  * 
2687  *                 if not os.path.exists( filename_index ):
2688  *                     raise IOError( "index `%s` not found" % filename_index)             # <<<<<<<<<<<<<<
2689  * 
2690  *             # open file and load index
2691  */
2692         __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), __pyx_v_filename_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2693         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
2694         __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2695         __Pyx_GOTREF(__pyx_t_2);
2696         PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
2697         __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
2698         __pyx_t_1 = 0;
2699         __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 = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2700         __Pyx_GOTREF(__pyx_t_1);
2701         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2702         __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2703         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2704         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2705         goto __pyx_L8;
2706       }
2707       __pyx_L8:;
2708       goto __pyx_L6;
2709     }
2710     __pyx_L6:;
2711
2712     /* "ctabix.pyx":138
2713  * 
2714  *             # open file and load index
2715  *             self.tabixfile = ti_open( filename, filename_index )             # <<<<<<<<<<<<<<
2716  * 
2717  *         if self.tabixfile == NULL:
2718  */
2719     __pyx_t_6 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2720     __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_index); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2721     __pyx_v_self->tabixfile = ti_open(__pyx_t_6, __pyx_t_8);
2722     goto __pyx_L5;
2723   }
2724   __pyx_L5:;
2725
2726   /* "ctabix.pyx":140
2727  *             self.tabixfile = ti_open( filename, filename_index )
2728  * 
2729  *         if self.tabixfile == NULL:             # <<<<<<<<<<<<<<
2730  *             raise IOError("could not open file `%s`" % filename )
2731  * 
2732  */
2733   __pyx_t_3 = (__pyx_v_self->tabixfile == NULL);
2734   if (__pyx_t_3) {
2735
2736     /* "ctabix.pyx":141
2737  * 
2738  *         if self.tabixfile == NULL:
2739  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
2740  * 
2741  *     def _parseRegion( self,
2742  */
2743     __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), __pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2744     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
2745     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2746     __Pyx_GOTREF(__pyx_t_2);
2747     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
2748     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
2749     __pyx_t_1 = 0;
2750     __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 = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2751     __Pyx_GOTREF(__pyx_t_1);
2752     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
2753     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2754     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2755     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2756     goto __pyx_L9;
2757   }
2758   __pyx_L9:;
2759
2760   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2761   goto __pyx_L0;
2762   __pyx_L1_error:;
2763   __Pyx_XDECREF(__pyx_t_1);
2764   __Pyx_XDECREF(__pyx_t_2);
2765   __Pyx_XDECREF(__pyx_t_4);
2766   __Pyx_AddTraceback("ctabix.Tabixfile._open", __pyx_clineno, __pyx_lineno, __pyx_filename);
2767   __pyx_r = NULL;
2768   __pyx_L0:;
2769   __Pyx_XDECREF(__pyx_v_filename_index);
2770   __Pyx_XDECREF(__pyx_v_bmode);
2771   __Pyx_XDECREF(__pyx_v_filename);
2772   __Pyx_XGIVEREF(__pyx_r);
2773   __Pyx_RefNannyFinishContext();
2774   return __pyx_r;
2775 }
2776
2777 /* Python wrapper */
2778 static PyObject *__pyx_pw_6ctabix_9Tabixfile_7_parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2779 static char __pyx_doc_6ctabix_9Tabixfile_6_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        ";
2780 static PyObject *__pyx_pw_6ctabix_9Tabixfile_7_parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2781   PyObject *__pyx_v_reference = 0;
2782   PyObject *__pyx_v_start = 0;
2783   PyObject *__pyx_v_end = 0;
2784   PyObject *__pyx_v_region = 0;
2785   PyObject *__pyx_r = 0;
2786   __Pyx_RefNannyDeclarations
2787   __Pyx_RefNannySetupContext("_parseRegion (wrapper)", 0);
2788   {
2789     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
2790     PyObject* values[4] = {0,0,0,0};
2791
2792     /* "ctabix.pyx":144
2793  * 
2794  *     def _parseRegion( self,
2795  *                       reference = None,             # <<<<<<<<<<<<<<
2796  *                       start = None,
2797  *                       end = None,
2798  */
2799     values[0] = ((PyObject *)Py_None);
2800
2801     /* "ctabix.pyx":145
2802  *     def _parseRegion( self,
2803  *                       reference = None,
2804  *                       start = None,             # <<<<<<<<<<<<<<
2805  *                       end = None,
2806  *                       region = None ):
2807  */
2808     values[1] = ((PyObject *)Py_None);
2809
2810     /* "ctabix.pyx":146
2811  *                       reference = None,
2812  *                       start = None,
2813  *                       end = None,             # <<<<<<<<<<<<<<
2814  *                       region = None ):
2815  *         '''parse region information.
2816  */
2817     values[2] = ((PyObject *)Py_None);
2818
2819     /* "ctabix.pyx":147
2820  *                       start = None,
2821  *                       end = None,
2822  *                       region = None ):             # <<<<<<<<<<<<<<
2823  *         '''parse region information.
2824  * 
2825  */
2826     values[3] = ((PyObject *)Py_None);
2827     if (unlikely(__pyx_kwds)) {
2828       Py_ssize_t kw_args;
2829       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2830       switch (pos_args) {
2831         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2832         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2833         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2834         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2835         case  0: break;
2836         default: goto __pyx_L5_argtuple_error;
2837       }
2838       kw_args = PyDict_Size(__pyx_kwds);
2839       switch (pos_args) {
2840         case  0:
2841         if (kw_args > 0) {
2842           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
2843           if (value) { values[0] = value; kw_args--; }
2844         }
2845         case  1:
2846         if (kw_args > 0) {
2847           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
2848           if (value) { values[1] = value; kw_args--; }
2849         }
2850         case  2:
2851         if (kw_args > 0) {
2852           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
2853           if (value) { values[2] = value; kw_args--; }
2854         }
2855         case  3:
2856         if (kw_args > 0) {
2857           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
2858           if (value) { values[3] = value; kw_args--; }
2859         }
2860       }
2861       if (unlikely(kw_args > 0)) {
2862         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2863       }
2864     } else {
2865       switch (PyTuple_GET_SIZE(__pyx_args)) {
2866         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2867         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2868         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2869         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2870         case  0: break;
2871         default: goto __pyx_L5_argtuple_error;
2872       }
2873     }
2874     __pyx_v_reference = values[0];
2875     __pyx_v_start = values[1];
2876     __pyx_v_end = values[2];
2877     __pyx_v_region = values[3];
2878   }
2879   goto __pyx_L4_argument_unpacking_done;
2880   __pyx_L5_argtuple_error:;
2881   __Pyx_RaiseArgtupleInvalid("_parseRegion", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2882   __pyx_L3_error:;
2883   __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion", __pyx_clineno, __pyx_lineno, __pyx_filename);
2884   __Pyx_RefNannyFinishContext();
2885   return NULL;
2886   __pyx_L4_argument_unpacking_done:;
2887   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_6_parseRegion(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self), __pyx_v_reference, __pyx_v_start, __pyx_v_end, __pyx_v_region);
2888   __Pyx_RefNannyFinishContext();
2889   return __pyx_r;
2890 }
2891
2892 /* "ctabix.pyx":143
2893  *             raise IOError("could not open file `%s`" % filename )
2894  * 
2895  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
2896  *                       reference = None,
2897  *                       start = None,
2898  */
2899
2900 static PyObject *__pyx_pf_6ctabix_9Tabixfile_6_parseRegion(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_region) {
2901   int __pyx_v_rtid;
2902   int __pyx_v_rstart;
2903   int __pyx_v_rend;
2904   int __pyx_v_max_pos;
2905   PyObject *__pyx_r = NULL;
2906   __Pyx_RefNannyDeclarations
2907   int __pyx_t_1;
2908   PyObject *__pyx_t_2 = NULL;
2909   int __pyx_t_3;
2910   int __pyx_t_4;
2911   PyObject *__pyx_t_5 = NULL;
2912   PyObject *__pyx_t_6 = NULL;
2913   char *__pyx_t_7;
2914   PyObject *__pyx_t_8 = NULL;
2915   int __pyx_lineno = 0;
2916   const char *__pyx_filename = NULL;
2917   int __pyx_clineno = 0;
2918   __Pyx_RefNannySetupContext("_parseRegion", 0);
2919   __Pyx_INCREF(__pyx_v_region);
2920
2921   /* "ctabix.pyx":158
2922  *         Note that regions are 1-based, while start,end are python coordinates.
2923  *         '''
2924  *         ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
2925  * 
2926  *         cdef int rtid
2927  */
2928   ti_lazy_index_load(__pyx_v_self->tabixfile);
2929
2930   /* "ctabix.pyx":164
2931  *         cdef int rend
2932  *         cdef int max_pos
2933  *         max_pos = 2 << 29             # <<<<<<<<<<<<<<
2934  * 
2935  *         rtid = rstart = rend = 0
2936  */
2937   __pyx_v_max_pos = 1073741824;
2938
2939   /* "ctabix.pyx":166
2940  *         max_pos = 2 << 29
2941  * 
2942  *         rtid = rstart = rend = 0             # <<<<<<<<<<<<<<
2943  * 
2944  *         # translate to a region
2945  */
2946   __pyx_v_rtid = 0;
2947   __pyx_v_rstart = 0;
2948   __pyx_v_rend = 0;
2949
2950   /* "ctabix.pyx":169
2951  * 
2952  *         # translate to a region
2953  *         if reference:             # <<<<<<<<<<<<<<
2954  *             if start != None and end != None:
2955  *                 region = "%s:%i-%i" % (reference, start+1, end)
2956  */
2957   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2958   if (__pyx_t_1) {
2959
2960     /* "ctabix.pyx":170
2961  *         # translate to a region
2962  *         if reference:
2963  *             if start != None and end != None:             # <<<<<<<<<<<<<<
2964  *                 region = "%s:%i-%i" % (reference, start+1, end)
2965  *             elif start == None and end != None:
2966  */
2967     __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2968     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2969     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2970     if (__pyx_t_1) {
2971       __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2972       __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2973       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2974       __pyx_t_4 = __pyx_t_3;
2975     } else {
2976       __pyx_t_4 = __pyx_t_1;
2977     }
2978     if (__pyx_t_4) {
2979
2980       /* "ctabix.pyx":171
2981  *         if reference:
2982  *             if start != None and end != None:
2983  *                 region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
2984  *             elif start == None and end != None:
2985  *                 region = "%s:%i-%i" % (reference, 1, end)
2986  */
2987       __pyx_t_2 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2988       __Pyx_GOTREF(__pyx_t_2);
2989       __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2990       __Pyx_GOTREF(__pyx_t_5);
2991       __Pyx_INCREF(__pyx_v_reference);
2992       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_reference);
2993       __Pyx_GIVEREF(__pyx_v_reference);
2994       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
2995       __Pyx_GIVEREF(__pyx_t_2);
2996       __Pyx_INCREF(__pyx_v_end);
2997       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_end);
2998       __Pyx_GIVEREF(__pyx_v_end);
2999       __pyx_t_2 = 0;
3000       __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3001       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3002       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
3003       __Pyx_DECREF(__pyx_v_region);
3004       __pyx_v_region = ((PyObject *)__pyx_t_2);
3005       __pyx_t_2 = 0;
3006       goto __pyx_L4;
3007     }
3008
3009     /* "ctabix.pyx":172
3010  *             if start != None and end != None:
3011  *                 region = "%s:%i-%i" % (reference, start+1, end)
3012  *             elif start == None and end != None:             # <<<<<<<<<<<<<<
3013  *                 region = "%s:%i-%i" % (reference, 1, end)
3014  *             elif end == None and start != None:
3015  */
3016     __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3017     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3018     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3019     if (__pyx_t_4) {
3020       __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3021       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3022       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3023       __pyx_t_3 = __pyx_t_1;
3024     } else {
3025       __pyx_t_3 = __pyx_t_4;
3026     }
3027     if (__pyx_t_3) {
3028
3029       /* "ctabix.pyx":173
3030  *                 region = "%s:%i-%i" % (reference, start+1, end)
3031  *             elif start == None and end != None:
3032  *                 region = "%s:%i-%i" % (reference, 1, end)             # <<<<<<<<<<<<<<
3033  *             elif end == None and start != None:
3034  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
3035  */
3036       __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3037       __Pyx_GOTREF(__pyx_t_2);
3038       __Pyx_INCREF(__pyx_v_reference);
3039       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
3040       __Pyx_GIVEREF(__pyx_v_reference);
3041       __Pyx_INCREF(__pyx_int_1);
3042       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1);
3043       __Pyx_GIVEREF(__pyx_int_1);
3044       __Pyx_INCREF(__pyx_v_end);
3045       PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
3046       __Pyx_GIVEREF(__pyx_v_end);
3047       __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3048       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
3049       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
3050       __Pyx_DECREF(__pyx_v_region);
3051       __pyx_v_region = ((PyObject *)__pyx_t_5);
3052       __pyx_t_5 = 0;
3053       goto __pyx_L4;
3054     }
3055
3056     /* "ctabix.pyx":174
3057  *             elif start == None and end != None:
3058  *                 region = "%s:%i-%i" % (reference, 1, end)
3059  *             elif end == None and start != None:             # <<<<<<<<<<<<<<
3060  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
3061  *             else:
3062  */
3063     __pyx_t_5 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3064     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3065     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3066     if (__pyx_t_3) {
3067       __pyx_t_5 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3068       __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3069       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3070       __pyx_t_1 = __pyx_t_4;
3071     } else {
3072       __pyx_t_1 = __pyx_t_3;
3073     }
3074     if (__pyx_t_1) {
3075
3076       /* "ctabix.pyx":175
3077  *                 region = "%s:%i-%i" % (reference, 1, end)
3078  *             elif end == None and start != None:
3079  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)             # <<<<<<<<<<<<<<
3080  *             else:
3081  *                 region = reference
3082  */
3083       __pyx_t_5 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3084       __Pyx_GOTREF(__pyx_t_5);
3085       __pyx_t_2 = PyInt_FromLong((__pyx_v_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3086       __Pyx_GOTREF(__pyx_t_2);
3087       __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3088       __Pyx_GOTREF(__pyx_t_6);
3089       __Pyx_INCREF(__pyx_v_reference);
3090       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reference);
3091       __Pyx_GIVEREF(__pyx_v_reference);
3092       PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
3093       __Pyx_GIVEREF(__pyx_t_5);
3094       PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
3095       __Pyx_GIVEREF(__pyx_t_2);
3096       __pyx_t_5 = 0;
3097       __pyx_t_2 = 0;
3098       __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3099       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3100       __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
3101       __Pyx_DECREF(__pyx_v_region);
3102       __pyx_v_region = ((PyObject *)__pyx_t_2);
3103       __pyx_t_2 = 0;
3104       goto __pyx_L4;
3105     }
3106     /*else*/ {
3107
3108       /* "ctabix.pyx":177
3109  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
3110  *             else:
3111  *                 region = reference             # <<<<<<<<<<<<<<
3112  * 
3113  *         if region:
3114  */
3115       __Pyx_INCREF(__pyx_v_reference);
3116       __Pyx_DECREF(__pyx_v_region);
3117       __pyx_v_region = __pyx_v_reference;
3118     }
3119     __pyx_L4:;
3120     goto __pyx_L3;
3121   }
3122   __pyx_L3:;
3123
3124   /* "ctabix.pyx":179
3125  *                 region = reference
3126  * 
3127  *         if region:             # <<<<<<<<<<<<<<
3128  *             region = _force_bytes(region)
3129  *             ti_parse_region( self.tabixfile.idx, region,
3130  */
3131   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3132   if (__pyx_t_1) {
3133
3134     /* "ctabix.pyx":180
3135  * 
3136  *         if region:
3137  *             region = _force_bytes(region)             # <<<<<<<<<<<<<<
3138  *             ti_parse_region( self.tabixfile.idx, region,
3139  *                              &rtid, &rstart, &rend)
3140  */
3141     __pyx_t_2 = ((PyObject *)__pyx_f_6ctabix__force_bytes(__pyx_v_region)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3142     __Pyx_GOTREF(__pyx_t_2);
3143     __Pyx_DECREF(__pyx_v_region);
3144     __pyx_v_region = __pyx_t_2;
3145     __pyx_t_2 = 0;
3146
3147     /* "ctabix.pyx":181
3148  *         if region:
3149  *             region = _force_bytes(region)
3150  *             ti_parse_region( self.tabixfile.idx, region,             # <<<<<<<<<<<<<<
3151  *                              &rtid, &rstart, &rend)
3152  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
3153  */
3154     __pyx_t_7 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3155
3156     /* "ctabix.pyx":182
3157  *             region = _force_bytes(region)
3158  *             ti_parse_region( self.tabixfile.idx, region,
3159  *                              &rtid, &rstart, &rend)             # <<<<<<<<<<<<<<
3160  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
3161  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
3162  */
3163     ti_parse_region(__pyx_v_self->tabixfile->idx, __pyx_t_7, (&__pyx_v_rtid), (&__pyx_v_rstart), (&__pyx_v_rend));
3164
3165     /* "ctabix.pyx":183
3166  *             ti_parse_region( self.tabixfile.idx, region,
3167  *                              &rtid, &rstart, &rend)
3168  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )             # <<<<<<<<<<<<<<
3169  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
3170  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
3171  */
3172     __pyx_t_1 = (__pyx_v_rtid < 0);
3173     if (__pyx_t_1) {
3174       __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_v_region); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3175       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3176       __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3177       __Pyx_GOTREF(__pyx_t_6);
3178       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
3179       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
3180       __pyx_t_2 = 0;
3181       __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 = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3182       __Pyx_GOTREF(__pyx_t_2);
3183       __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
3184       __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3185       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3186       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3187       goto __pyx_L6;
3188     }
3189     __pyx_L6:;
3190
3191     /* "ctabix.pyx":184
3192  *                              &rtid, &rstart, &rend)
3193  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
3194  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )             # <<<<<<<<<<<<<<
3195  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
3196  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
3197  */
3198     __pyx_t_1 = (__pyx_v_rstart > __pyx_v_rend);
3199     if (__pyx_t_1) {
3200       __pyx_t_2 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3201       __Pyx_GOTREF(__pyx_t_2);
3202       __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3203       __Pyx_GOTREF(__pyx_t_6);
3204       __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3205       __Pyx_GOTREF(__pyx_t_5);
3206       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
3207       __Pyx_GIVEREF(__pyx_t_2);
3208       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
3209       __Pyx_GIVEREF(__pyx_t_6);
3210       __pyx_t_2 = 0;
3211       __pyx_t_6 = 0;
3212       __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3213       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
3214       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
3215       __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3216       __Pyx_GOTREF(__pyx_t_5);
3217       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
3218       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
3219       __pyx_t_6 = 0;
3220       __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 = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3221       __Pyx_GOTREF(__pyx_t_6);
3222       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
3223       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
3224       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3225       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3226       goto __pyx_L7;
3227     }
3228     __pyx_L7:;
3229
3230     /* "ctabix.pyx":185
3231  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
3232  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
3233  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )             # <<<<<<<<<<<<<<
3234  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
3235  * 
3236  */
3237     __pyx_t_1 = (0 <= __pyx_v_rstart);
3238     if (__pyx_t_1) {
3239       __pyx_t_1 = (__pyx_v_rstart < __pyx_v_max_pos);
3240     }
3241     __pyx_t_3 = (!__pyx_t_1);
3242     if (__pyx_t_3) {
3243       __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3244       __Pyx_GOTREF(__pyx_t_6);
3245       __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_20), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3246       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
3247       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3248       __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3249       __Pyx_GOTREF(__pyx_t_6);
3250       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
3251       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
3252       __pyx_t_5 = 0;
3253       __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 = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3254       __Pyx_GOTREF(__pyx_t_5);
3255       __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
3256       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
3257       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3258       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3259       goto __pyx_L8;
3260     }
3261     __pyx_L8:;
3262
3263     /* "ctabix.pyx":186
3264  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
3265  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
3266  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )             # <<<<<<<<<<<<<<
3267  * 
3268  *         return region, rtid, rstart, rend
3269  */
3270     __pyx_t_3 = (0 <= __pyx_v_rend);
3271     if (__pyx_t_3) {
3272       __pyx_t_3 = (__pyx_v_rend < __pyx_v_max_pos);
3273     }
3274     __pyx_t_1 = (!__pyx_t_3);
3275     if (__pyx_t_1) {
3276       __pyx_t_5 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3277       __Pyx_GOTREF(__pyx_t_5);
3278       __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3279       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
3280       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3281       __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3282       __Pyx_GOTREF(__pyx_t_5);
3283       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
3284       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
3285       __pyx_t_6 = 0;
3286       __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 = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3287       __Pyx_GOTREF(__pyx_t_6);
3288       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
3289       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
3290       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3291       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3292       goto __pyx_L9;
3293     }
3294     __pyx_L9:;
3295     goto __pyx_L5;
3296   }
3297   __pyx_L5:;
3298
3299   /* "ctabix.pyx":188
3300  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
3301  * 
3302  *         return region, rtid, rstart, rend             # <<<<<<<<<<<<<<
3303  * 
3304  *     def fetch( self,
3305  */
3306   __Pyx_XDECREF(__pyx_r);
3307   __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3308   __Pyx_GOTREF(__pyx_t_6);
3309   __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3310   __Pyx_GOTREF(__pyx_t_5);
3311   __pyx_t_2 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3312   __Pyx_GOTREF(__pyx_t_2);
3313   __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3314   __Pyx_GOTREF(__pyx_t_8);
3315   __Pyx_INCREF(__pyx_v_region);
3316   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_region);
3317   __Pyx_GIVEREF(__pyx_v_region);
3318   PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
3319   __Pyx_GIVEREF(__pyx_t_6);
3320   PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
3321   __Pyx_GIVEREF(__pyx_t_5);
3322   PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_2);
3323   __Pyx_GIVEREF(__pyx_t_2);
3324   __pyx_t_6 = 0;
3325   __pyx_t_5 = 0;
3326   __pyx_t_2 = 0;
3327   __pyx_r = ((PyObject *)__pyx_t_8);
3328   __pyx_t_8 = 0;
3329   goto __pyx_L0;
3330
3331   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3332   goto __pyx_L0;
3333   __pyx_L1_error:;
3334   __Pyx_XDECREF(__pyx_t_2);
3335   __Pyx_XDECREF(__pyx_t_5);
3336   __Pyx_XDECREF(__pyx_t_6);
3337   __Pyx_XDECREF(__pyx_t_8);
3338   __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion", __pyx_clineno, __pyx_lineno, __pyx_filename);
3339   __pyx_r = NULL;
3340   __pyx_L0:;
3341   __Pyx_XDECREF(__pyx_v_region);
3342   __Pyx_XGIVEREF(__pyx_r);
3343   __Pyx_RefNannyFinishContext();
3344   return __pyx_r;
3345 }
3346
3347 /* Python wrapper */
3348 static PyObject *__pyx_pw_6ctabix_9Tabixfile_9fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3349 static char __pyx_doc_6ctabix_9Tabixfile_8fetch[] = "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        ";
3350 static PyObject *__pyx_pw_6ctabix_9Tabixfile_9fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3351   PyObject *__pyx_v_reference = 0;
3352   PyObject *__pyx_v_start = 0;
3353   PyObject *__pyx_v_end = 0;
3354   PyObject *__pyx_v_region = 0;
3355   PyObject *__pyx_v_parser = 0;
3356   PyObject *__pyx_r = 0;
3357   __Pyx_RefNannyDeclarations
3358   __Pyx_RefNannySetupContext("fetch (wrapper)", 0);
3359   {
3360     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};
3361     PyObject* values[5] = {0,0,0,0,0};
3362
3363     /* "ctabix.pyx":191
3364  * 
3365  *     def fetch( self,
3366  *                reference = None,             # <<<<<<<<<<<<<<
3367  *                start = None,
3368  *                end = None,
3369  */
3370     values[0] = ((PyObject *)Py_None);
3371
3372     /* "ctabix.pyx":192
3373  *     def fetch( self,
3374  *                reference = None,
3375  *                start = None,             # <<<<<<<<<<<<<<
3376  *                end = None,
3377  *                region = None,
3378  */
3379     values[1] = ((PyObject *)Py_None);
3380
3381     /* "ctabix.pyx":193
3382  *                reference = None,
3383  *                start = None,
3384  *                end = None,             # <<<<<<<<<<<<<<
3385  *                region = None,
3386  *                parser = None ):
3387  */
3388     values[2] = ((PyObject *)Py_None);
3389
3390     /* "ctabix.pyx":194
3391  *                start = None,
3392  *                end = None,
3393  *                region = None,             # <<<<<<<<<<<<<<
3394  *                parser = None ):
3395  *         '''
3396  */
3397     values[3] = ((PyObject *)Py_None);
3398
3399     /* "ctabix.pyx":195
3400  *                end = None,
3401  *                region = None,
3402  *                parser = None ):             # <<<<<<<<<<<<<<
3403  *         '''
3404  * 
3405  */
3406     values[4] = ((PyObject *)Py_None);
3407     if (unlikely(__pyx_kwds)) {
3408       Py_ssize_t kw_args;
3409       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3410       switch (pos_args) {
3411         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3412         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3413         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3414         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3415         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3416         case  0: break;
3417         default: goto __pyx_L5_argtuple_error;
3418       }
3419       kw_args = PyDict_Size(__pyx_kwds);
3420       switch (pos_args) {
3421         case  0:
3422         if (kw_args > 0) {
3423           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
3424           if (value) { values[0] = value; kw_args--; }
3425         }
3426         case  1:
3427         if (kw_args > 0) {
3428           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
3429           if (value) { values[1] = value; kw_args--; }
3430         }
3431         case  2:
3432         if (kw_args > 0) {
3433           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
3434           if (value) { values[2] = value; kw_args--; }
3435         }
3436         case  3:
3437         if (kw_args > 0) {
3438           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
3439           if (value) { values[3] = value; kw_args--; }
3440         }
3441         case  4:
3442         if (kw_args > 0) {
3443           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser);
3444           if (value) { values[4] = value; kw_args--; }
3445         }
3446       }
3447       if (unlikely(kw_args > 0)) {
3448         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3449       }
3450     } else {
3451       switch (PyTuple_GET_SIZE(__pyx_args)) {
3452         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3453         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3454         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3455         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3456         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3457         case  0: break;
3458         default: goto __pyx_L5_argtuple_error;
3459       }
3460     }
3461     __pyx_v_reference = values[0];
3462     __pyx_v_start = values[1];
3463     __pyx_v_end = values[2];
3464     __pyx_v_region = values[3];
3465     __pyx_v_parser = values[4];
3466   }
3467   goto __pyx_L4_argument_unpacking_done;
3468   __pyx_L5_argtuple_error:;
3469   __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3470   __pyx_L3_error:;
3471   __Pyx_AddTraceback("ctabix.Tabixfile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
3472   __Pyx_RefNannyFinishContext();
3473   return NULL;
3474   __pyx_L4_argument_unpacking_done:;
3475   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_8fetch(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self), __pyx_v_reference, __pyx_v_start, __pyx_v_end, __pyx_v_region, __pyx_v_parser);
3476   __Pyx_RefNannyFinishContext();
3477   return __pyx_r;
3478 }
3479
3480 /* "ctabix.pyx":190
3481  *         return region, rtid, rstart, rend
3482  * 
3483  *     def fetch( self,             # <<<<<<<<<<<<<<
3484  *                reference = None,
3485  *                start = None,
3486  */
3487
3488 static PyObject *__pyx_pf_6ctabix_9Tabixfile_8fetch(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_region, PyObject *__pyx_v_parser) {
3489   PyObject *__pyx_v_rtid = NULL;
3490   PyObject *__pyx_v_rstart = NULL;
3491   PyObject *__pyx_v_rend = NULL;
3492   PyObject *__pyx_r = NULL;
3493   __Pyx_RefNannyDeclarations
3494   PyObject *__pyx_t_1 = NULL;
3495   PyObject *__pyx_t_2 = NULL;
3496   int __pyx_t_3;
3497   int __pyx_t_4;
3498   PyObject *__pyx_t_5 = NULL;
3499   PyObject *__pyx_t_6 = NULL;
3500   PyObject *__pyx_t_7 = NULL;
3501   PyObject *__pyx_t_8 = NULL;
3502   PyObject *(*__pyx_t_9)(PyObject *);
3503   int __pyx_lineno = 0;
3504   const char *__pyx_filename = NULL;
3505   int __pyx_clineno = 0;
3506   __Pyx_RefNannySetupContext("fetch", 0);
3507   __Pyx_INCREF(__pyx_v_region);
3508
3509   /* "ctabix.pyx":209
3510  *         data (see for example :meth:`asTuple` and :meth:`asGTF`).
3511  *         '''
3512  *         ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
3513  * 
3514  *         if not self._isOpen():
3515  */
3516   ti_lazy_index_load(__pyx_v_self->tabixfile);
3517
3518   /* "ctabix.pyx":211
3519  *         ti_lazy_index_load( self.tabixfile )
3520  * 
3521  *         if not self._isOpen():             # <<<<<<<<<<<<<<
3522  *             raise ValueError( "I/O operation on closed file" )
3523  * 
3524  */
3525   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3526   __Pyx_GOTREF(__pyx_t_1);
3527   __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 = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3528   __Pyx_GOTREF(__pyx_t_2);
3529   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3530   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3531   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3532   __pyx_t_4 = (!__pyx_t_3);
3533   if (__pyx_t_4) {
3534
3535     /* "ctabix.pyx":212
3536  * 
3537  *         if not self._isOpen():
3538  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
3539  * 
3540  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
3541  */
3542     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3543     __Pyx_GOTREF(__pyx_t_2);
3544     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3545     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3546     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3547     goto __pyx_L3;
3548   }
3549   __pyx_L3:;
3550
3551   /* "ctabix.pyx":214
3552  *             raise ValueError( "I/O operation on closed file" )
3553  * 
3554  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
3555  * 
3556  *         if parser == None:
3557  */
3558   __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3559   __Pyx_GOTREF(__pyx_t_2);
3560   __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3561   __Pyx_GOTREF(__pyx_t_1);
3562   __Pyx_INCREF(__pyx_v_reference);
3563   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
3564   __Pyx_GIVEREF(__pyx_v_reference);
3565   __Pyx_INCREF(__pyx_v_start);
3566   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_start);
3567   __Pyx_GIVEREF(__pyx_v_start);
3568   __Pyx_INCREF(__pyx_v_end);
3569   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
3570   __Pyx_GIVEREF(__pyx_v_end);
3571   __Pyx_INCREF(__pyx_v_region);
3572   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
3573   __Pyx_GIVEREF(__pyx_v_region);
3574   __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 = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3575   __Pyx_GOTREF(__pyx_t_5);
3576   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3577   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
3578   if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
3579     PyObject* sequence = __pyx_t_5;
3580     #if CYTHON_COMPILING_IN_CPYTHON
3581     Py_ssize_t size = Py_SIZE(sequence);
3582     #else
3583     Py_ssize_t size = PySequence_Size(sequence);
3584     #endif
3585     if (unlikely(size != 4)) {
3586       if (size > 4) __Pyx_RaiseTooManyValuesError(4);
3587       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
3588       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3589     }
3590     #if CYTHON_COMPILING_IN_CPYTHON
3591     if (likely(PyTuple_CheckExact(sequence))) {
3592       __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
3593       __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
3594       __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
3595       __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); 
3596     } else {
3597       __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
3598       __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
3599       __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
3600       __pyx_t_7 = PyList_GET_ITEM(sequence, 3); 
3601     }
3602     __Pyx_INCREF(__pyx_t_1);
3603     __Pyx_INCREF(__pyx_t_2);
3604     __Pyx_INCREF(__pyx_t_6);
3605     __Pyx_INCREF(__pyx_t_7);
3606     #else
3607     Py_ssize_t i;
3608     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
3609     for (i=0; i < 4; i++) {
3610       PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3611       *(temps[i]) = item;
3612     }
3613     #endif
3614     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3615   } else
3616   {
3617     Py_ssize_t index = -1;
3618     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
3619     __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3620     __Pyx_GOTREF(__pyx_t_8);
3621     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3622     __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
3623     for (index=0; index < 4; index++) {
3624       PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L4_unpacking_failed;
3625       __Pyx_GOTREF(item);
3626       *(temps[index]) = item;
3627     }
3628     if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3629     __pyx_t_9 = NULL;
3630     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3631     goto __pyx_L5_unpacking_done;
3632     __pyx_L4_unpacking_failed:;
3633     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3634     __pyx_t_9 = NULL;
3635     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
3636     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3637     __pyx_L5_unpacking_done:;
3638   }
3639   __Pyx_DECREF(__pyx_v_region);
3640   __pyx_v_region = __pyx_t_1;
3641   __pyx_t_1 = 0;
3642   __pyx_v_rtid = __pyx_t_2;
3643   __pyx_t_2 = 0;
3644   __pyx_v_rstart = __pyx_t_6;
3645   __pyx_t_6 = 0;
3646   __pyx_v_rend = __pyx_t_7;
3647   __pyx_t_7 = 0;
3648
3649   /* "ctabix.pyx":216
3650  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
3651  * 
3652  *         if parser == None:             # <<<<<<<<<<<<<<
3653  *             if region:
3654  *                 return TabixIterator( self, rtid, rstart, rend )
3655  */
3656   __pyx_t_5 = PyObject_RichCompare(__pyx_v_parser, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3657   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3658   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3659   if (__pyx_t_4) {
3660
3661     /* "ctabix.pyx":217
3662  * 
3663  *         if parser == None:
3664  *             if region:             # <<<<<<<<<<<<<<
3665  *                 return TabixIterator( self, rtid, rstart, rend )
3666  *             else:
3667  */
3668     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3669     if (__pyx_t_4) {
3670
3671       /* "ctabix.pyx":218
3672  *         if parser == None:
3673  *             if region:
3674  *                 return TabixIterator( self, rtid, rstart, rend )             # <<<<<<<<<<<<<<
3675  *             else:
3676  *                 return TabixIterator( self, -1, 0, 0 )
3677  */
3678       __Pyx_XDECREF(__pyx_r);
3679       __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3680       __Pyx_GOTREF(__pyx_t_5);
3681       __Pyx_INCREF(((PyObject *)__pyx_v_self));
3682       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
3683       __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
3684       __Pyx_INCREF(__pyx_v_rtid);
3685       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_rtid);
3686       __Pyx_GIVEREF(__pyx_v_rtid);
3687       __Pyx_INCREF(__pyx_v_rstart);
3688       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_rstart);
3689       __Pyx_GIVEREF(__pyx_v_rstart);
3690       __Pyx_INCREF(__pyx_v_rend);
3691       PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_rend);
3692       __Pyx_GIVEREF(__pyx_v_rend);
3693       __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 = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3694       __Pyx_GOTREF(__pyx_t_7);
3695       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
3696       __pyx_r = __pyx_t_7;
3697       __pyx_t_7 = 0;
3698       goto __pyx_L0;
3699       goto __pyx_L7;
3700     }
3701     /*else*/ {
3702
3703       /* "ctabix.pyx":220
3704  *                 return TabixIterator( self, rtid, rstart, rend )
3705  *             else:
3706  *                 return TabixIterator( self, -1, 0, 0 )             # <<<<<<<<<<<<<<
3707  *         else:
3708  *             if region:
3709  */
3710       __Pyx_XDECREF(__pyx_r);
3711       __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3712       __Pyx_GOTREF(__pyx_t_7);
3713       __Pyx_INCREF(((PyObject *)__pyx_v_self));
3714       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self));
3715       __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
3716       __Pyx_INCREF(__pyx_int_neg_1);
3717       PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1);
3718       __Pyx_GIVEREF(__pyx_int_neg_1);
3719       __Pyx_INCREF(__pyx_int_0);
3720       PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0);
3721       __Pyx_GIVEREF(__pyx_int_0);
3722       __Pyx_INCREF(__pyx_int_0);
3723       PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_int_0);
3724       __Pyx_GIVEREF(__pyx_int_0);
3725       __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 = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3726       __Pyx_GOTREF(__pyx_t_5);
3727       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
3728       __pyx_r = __pyx_t_5;
3729       __pyx_t_5 = 0;
3730       goto __pyx_L0;
3731     }
3732     __pyx_L7:;
3733     goto __pyx_L6;
3734   }
3735   /*else*/ {
3736
3737     /* "ctabix.pyx":222
3738  *                 return TabixIterator( self, -1, 0, 0 )
3739  *         else:
3740  *             if region:             # <<<<<<<<<<<<<<
3741  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )
3742  *             else:
3743  */
3744     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3745     if (__pyx_t_4) {
3746
3747       /* "ctabix.pyx":223
3748  *         else:
3749  *             if region:
3750  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )             # <<<<<<<<<<<<<<
3751  *             else:
3752  *                 return TabixIteratorParsed( self, -1, 0, 0, parser )
3753  */
3754       __Pyx_XDECREF(__pyx_r);
3755       __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3756       __Pyx_GOTREF(__pyx_t_5);
3757       __Pyx_INCREF(((PyObject *)__pyx_v_self));
3758       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
3759       __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
3760       __Pyx_INCREF(__pyx_v_rtid);
3761       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_rtid);
3762       __Pyx_GIVEREF(__pyx_v_rtid);
3763       __Pyx_INCREF(__pyx_v_rstart);
3764       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_rstart);
3765       __Pyx_GIVEREF(__pyx_v_rstart);
3766       __Pyx_INCREF(__pyx_v_rend);
3767       PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_rend);
3768       __Pyx_GIVEREF(__pyx_v_rend);
3769       __Pyx_INCREF(__pyx_v_parser);
3770       PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_parser);
3771       __Pyx_GIVEREF(__pyx_v_parser);
3772       __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 = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3773       __Pyx_GOTREF(__pyx_t_7);
3774       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
3775       __pyx_r = __pyx_t_7;
3776       __pyx_t_7 = 0;
3777       goto __pyx_L0;
3778       goto __pyx_L8;
3779     }
3780     /*else*/ {
3781
3782       /* "ctabix.pyx":225
3783  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )
3784  *             else:
3785  *                 return TabixIteratorParsed( self, -1, 0, 0, parser )             # <<<<<<<<<<<<<<
3786  * 
3787  *     ###############################################################
3788  */
3789       __Pyx_XDECREF(__pyx_r);
3790       __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3791       __Pyx_GOTREF(__pyx_t_7);
3792       __Pyx_INCREF(((PyObject *)__pyx_v_self));
3793       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self));
3794       __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
3795       __Pyx_INCREF(__pyx_int_neg_1);
3796       PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1);
3797       __Pyx_GIVEREF(__pyx_int_neg_1);
3798       __Pyx_INCREF(__pyx_int_0);
3799       PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0);
3800       __Pyx_GIVEREF(__pyx_int_0);
3801       __Pyx_INCREF(__pyx_int_0);
3802       PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_int_0);
3803       __Pyx_GIVEREF(__pyx_int_0);
3804       __Pyx_INCREF(__pyx_v_parser);
3805       PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_parser);
3806       __Pyx_GIVEREF(__pyx_v_parser);
3807       __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 = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3808       __Pyx_GOTREF(__pyx_t_5);
3809       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
3810       __pyx_r = __pyx_t_5;
3811       __pyx_t_5 = 0;
3812       goto __pyx_L0;
3813     }
3814     __pyx_L8:;
3815   }
3816   __pyx_L6:;
3817
3818   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3819   goto __pyx_L0;
3820   __pyx_L1_error:;
3821   __Pyx_XDECREF(__pyx_t_1);
3822   __Pyx_XDECREF(__pyx_t_2);
3823   __Pyx_XDECREF(__pyx_t_5);
3824   __Pyx_XDECREF(__pyx_t_6);
3825   __Pyx_XDECREF(__pyx_t_7);
3826   __Pyx_XDECREF(__pyx_t_8);
3827   __Pyx_AddTraceback("ctabix.Tabixfile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
3828   __pyx_r = NULL;
3829   __pyx_L0:;
3830   __Pyx_XDECREF(__pyx_v_rtid);
3831   __Pyx_XDECREF(__pyx_v_rstart);
3832   __Pyx_XDECREF(__pyx_v_rend);
3833   __Pyx_XDECREF(__pyx_v_region);
3834   __Pyx_XGIVEREF(__pyx_r);
3835   __Pyx_RefNannyFinishContext();
3836   return __pyx_r;
3837 }
3838
3839 /* Python wrapper */
3840 static PyObject *__pyx_pw_6ctabix_9Tabixfile_8filename_1__get__(PyObject *__pyx_v_self); /*proto*/
3841 static PyObject *__pyx_pw_6ctabix_9Tabixfile_8filename_1__get__(PyObject *__pyx_v_self) {
3842   PyObject *__pyx_r = 0;
3843   __Pyx_RefNannyDeclarations
3844   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
3845   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_8filename___get__(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self));
3846   __Pyx_RefNannyFinishContext();
3847   return __pyx_r;
3848 }
3849
3850 /* "ctabix.pyx":234
3851  *     property filename:
3852  *         '''filename associated with this object.'''
3853  *         def __get__(self):             # <<<<<<<<<<<<<<
3854  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
3855  *             return self._filename
3856  */
3857
3858 static PyObject *__pyx_pf_6ctabix_9Tabixfile_8filename___get__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self) {
3859   PyObject *__pyx_r = NULL;
3860   __Pyx_RefNannyDeclarations
3861   PyObject *__pyx_t_1 = NULL;
3862   PyObject *__pyx_t_2 = NULL;
3863   int __pyx_t_3;
3864   int __pyx_t_4;
3865   int __pyx_lineno = 0;
3866   const char *__pyx_filename = NULL;
3867   int __pyx_clineno = 0;
3868   __Pyx_RefNannySetupContext("__get__", 0);
3869
3870   /* "ctabix.pyx":235
3871  *         '''filename associated with this object.'''
3872  *         def __get__(self):
3873  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
3874  *             return self._filename
3875  * 
3876  */
3877   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3878   __Pyx_GOTREF(__pyx_t_1);
3879   __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 = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3880   __Pyx_GOTREF(__pyx_t_2);
3881   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3882   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3883   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3884   __pyx_t_4 = (!__pyx_t_3);
3885   if (__pyx_t_4) {
3886     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3887     __Pyx_GOTREF(__pyx_t_2);
3888     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3889     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3890     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3891     goto __pyx_L3;
3892   }
3893   __pyx_L3:;
3894
3895   /* "ctabix.pyx":236
3896  *         def __get__(self):
3897  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
3898  *             return self._filename             # <<<<<<<<<<<<<<
3899  * 
3900  *     property header:
3901  */
3902   __Pyx_XDECREF(__pyx_r);
3903   __pyx_t_2 = PyBytes_FromString(__pyx_v_self->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3904   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3905   __pyx_r = ((PyObject *)__pyx_t_2);
3906   __pyx_t_2 = 0;
3907   goto __pyx_L0;
3908
3909   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3910   goto __pyx_L0;
3911   __pyx_L1_error:;
3912   __Pyx_XDECREF(__pyx_t_1);
3913   __Pyx_XDECREF(__pyx_t_2);
3914   __Pyx_AddTraceback("ctabix.Tabixfile.filename.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3915   __pyx_r = NULL;
3916   __pyx_L0:;
3917   __Pyx_XGIVEREF(__pyx_r);
3918   __Pyx_RefNannyFinishContext();
3919   return __pyx_r;
3920 }
3921
3922 /* Python wrapper */
3923 static PyObject *__pyx_pw_6ctabix_9Tabixfile_6header_1__get__(PyObject *__pyx_v_self); /*proto*/
3924 static PyObject *__pyx_pw_6ctabix_9Tabixfile_6header_1__get__(PyObject *__pyx_v_self) {
3925   PyObject *__pyx_r = 0;
3926   __Pyx_RefNannyDeclarations
3927   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
3928   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_6header___get__(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self));
3929   __Pyx_RefNannyFinishContext();
3930   return __pyx_r;
3931 }
3932
3933 /* "ctabix.pyx":246
3934  *         '''
3935  * 
3936  *         def __get__( self ):             # <<<<<<<<<<<<<<
3937  *             return TabixHeaderIterator( self )
3938  * 
3939  */
3940
3941 static PyObject *__pyx_pf_6ctabix_9Tabixfile_6header___get__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self) {
3942   PyObject *__pyx_r = NULL;
3943   __Pyx_RefNannyDeclarations
3944   PyObject *__pyx_t_1 = NULL;
3945   PyObject *__pyx_t_2 = NULL;
3946   int __pyx_lineno = 0;
3947   const char *__pyx_filename = NULL;
3948   int __pyx_clineno = 0;
3949   __Pyx_RefNannySetupContext("__get__", 0);
3950
3951   /* "ctabix.pyx":247
3952  * 
3953  *         def __get__( self ):
3954  *             return TabixHeaderIterator( self )             # <<<<<<<<<<<<<<
3955  * 
3956  *     property contigs:
3957  */
3958   __Pyx_XDECREF(__pyx_r);
3959   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3960   __Pyx_GOTREF(__pyx_t_1);
3961   __Pyx_INCREF(((PyObject *)__pyx_v_self));
3962   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
3963   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
3964   __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 = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3965   __Pyx_GOTREF(__pyx_t_2);
3966   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
3967   __pyx_r = __pyx_t_2;
3968   __pyx_t_2 = 0;
3969   goto __pyx_L0;
3970
3971   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3972   goto __pyx_L0;
3973   __pyx_L1_error:;
3974   __Pyx_XDECREF(__pyx_t_1);
3975   __Pyx_XDECREF(__pyx_t_2);
3976   __Pyx_AddTraceback("ctabix.Tabixfile.header.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3977   __pyx_r = NULL;
3978   __pyx_L0:;
3979   __Pyx_XGIVEREF(__pyx_r);
3980   __Pyx_RefNannyFinishContext();
3981   return __pyx_r;
3982 }
3983
3984 /* Python wrapper */
3985 static PyObject *__pyx_pw_6ctabix_9Tabixfile_7contigs_1__get__(PyObject *__pyx_v_self); /*proto*/
3986 static PyObject *__pyx_pw_6ctabix_9Tabixfile_7contigs_1__get__(PyObject *__pyx_v_self) {
3987   PyObject *__pyx_r = 0;
3988   __Pyx_RefNannyDeclarations
3989   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
3990   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_7contigs___get__(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self));
3991   __Pyx_RefNannyFinishContext();
3992   return __pyx_r;
3993 }
3994
3995 /* "ctabix.pyx":251
3996  *     property contigs:
3997  *         '''chromosome names'''
3998  *         def __get__(self):             # <<<<<<<<<<<<<<
3999  *             cdef char ** sequences
4000  *             cdef int nsequences
4001  */
4002
4003 static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self) {
4004   char **__pyx_v_sequences;
4005   int __pyx_v_nsequences;
4006   int __pyx_v_x;
4007   PyObject *__pyx_v_result = NULL;
4008   PyObject *__pyx_r = NULL;
4009   __Pyx_RefNannyDeclarations
4010   PyObject *__pyx_t_1 = NULL;
4011   int __pyx_t_2;
4012   int __pyx_t_3;
4013   int __pyx_lineno = 0;
4014   const char *__pyx_filename = NULL;
4015   int __pyx_clineno = 0;
4016   __Pyx_RefNannySetupContext("__get__", 0);
4017
4018   /* "ctabix.pyx":255
4019  *             cdef int nsequences
4020  * 
4021  *             ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
4022  *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )
4023  *             cdef int x
4024  */
4025   ti_lazy_index_load(__pyx_v_self->tabixfile);
4026
4027   /* "ctabix.pyx":256
4028  * 
4029  *             ti_lazy_index_load( self.tabixfile )
4030  *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )             # <<<<<<<<<<<<<<
4031  *             cdef int x
4032  *             result = []
4033  */
4034   __pyx_v_sequences = ti_seqname(__pyx_v_self->tabixfile->idx, (&__pyx_v_nsequences));
4035
4036   /* "ctabix.pyx":258
4037  *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )
4038  *             cdef int x
4039  *             result = []             # <<<<<<<<<<<<<<
4040  *             for x from 0 <= x < nsequences:
4041  *                 result.append( sequences[x] )
4042  */
4043   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4044   __Pyx_GOTREF(__pyx_t_1);
4045   __pyx_v_result = __pyx_t_1;
4046   __pyx_t_1 = 0;
4047
4048   /* "ctabix.pyx":259
4049  *             cdef int x
4050  *             result = []
4051  *             for x from 0 <= x < nsequences:             # <<<<<<<<<<<<<<
4052  *                 result.append( sequences[x] )
4053  *             return result
4054  */
4055   __pyx_t_2 = __pyx_v_nsequences;
4056   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
4057
4058     /* "ctabix.pyx":260
4059  *             result = []
4060  *             for x from 0 <= x < nsequences:
4061  *                 result.append( sequences[x] )             # <<<<<<<<<<<<<<
4062  *             return result
4063  * 
4064  */
4065     __pyx_t_1 = PyBytes_FromString((__pyx_v_sequences[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4066     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4067     __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 = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4068     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
4069   }
4070
4071   /* "ctabix.pyx":261
4072  *             for x from 0 <= x < nsequences:
4073  *                 result.append( sequences[x] )
4074  *             return result             # <<<<<<<<<<<<<<
4075  * 
4076  *     def close( self ):
4077  */
4078   __Pyx_XDECREF(__pyx_r);
4079   __Pyx_INCREF(((PyObject *)__pyx_v_result));
4080   __pyx_r = ((PyObject *)__pyx_v_result);
4081   goto __pyx_L0;
4082
4083   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4084   goto __pyx_L0;
4085   __pyx_L1_error:;
4086   __Pyx_XDECREF(__pyx_t_1);
4087   __Pyx_AddTraceback("ctabix.Tabixfile.contigs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4088   __pyx_r = NULL;
4089   __pyx_L0:;
4090   __Pyx_XDECREF(__pyx_v_result);
4091   __Pyx_XGIVEREF(__pyx_r);
4092   __Pyx_RefNannyFinishContext();
4093   return __pyx_r;
4094 }
4095
4096 /* Python wrapper */
4097 static PyObject *__pyx_pw_6ctabix_9Tabixfile_11close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4098 static char __pyx_doc_6ctabix_9Tabixfile_10close[] = "Tabixfile.close(self)\n\n        closes the :class:`pysam.Tabixfile`.";
4099 static PyObject *__pyx_pw_6ctabix_9Tabixfile_11close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4100   PyObject *__pyx_r = 0;
4101   __Pyx_RefNannyDeclarations
4102   __Pyx_RefNannySetupContext("close (wrapper)", 0);
4103   __pyx_r = __pyx_pf_6ctabix_9Tabixfile_10close(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self));
4104   __Pyx_RefNannyFinishContext();
4105   return __pyx_r;
4106 }
4107
4108 /* "ctabix.pyx":263
4109  *             return result
4110  * 
4111  *     def close( self ):             # <<<<<<<<<<<<<<
4112  *         '''
4113  *         closes the :class:`pysam.Tabixfile`.'''
4114  */
4115
4116 static PyObject *__pyx_pf_6ctabix_9Tabixfile_10close(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self) {
4117   PyObject *__pyx_r = NULL;
4118   __Pyx_RefNannyDeclarations
4119   int __pyx_t_1;
4120   __Pyx_RefNannySetupContext("close", 0);
4121
4122   /* "ctabix.pyx":266
4123  *         '''
4124  *         closes the :class:`pysam.Tabixfile`.'''
4125  *         if self.tabixfile != NULL:             # <<<<<<<<<<<<<<
4126  *             ti_close( self.tabixfile )
4127  *             self.tabixfile = NULL
4128  */
4129   __pyx_t_1 = (__pyx_v_self->tabixfile != NULL);
4130   if (__pyx_t_1) {
4131
4132     /* "ctabix.pyx":267
4133  *         closes the :class:`pysam.Tabixfile`.'''
4134  *         if self.tabixfile != NULL:
4135  *             ti_close( self.tabixfile )             # <<<<<<<<<<<<<<
4136  *             self.tabixfile = NULL
4137  * 
4138  */
4139     ti_close(__pyx_v_self->tabixfile);
4140
4141     /* "ctabix.pyx":268
4142  *         if self.tabixfile != NULL:
4143  *             ti_close( self.tabixfile )
4144  *             self.tabixfile = NULL             # <<<<<<<<<<<<<<
4145  * 
4146  *     def __dealloc__( self ):
4147  */
4148     __pyx_v_self->tabixfile = NULL;
4149     goto __pyx_L3;
4150   }
4151   __pyx_L3:;
4152
4153   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4154   __Pyx_XGIVEREF(__pyx_r);
4155   __Pyx_RefNannyFinishContext();
4156   return __pyx_r;
4157 }
4158
4159 /* Python wrapper */
4160 static void __pyx_pw_6ctabix_9Tabixfile_13__dealloc__(PyObject *__pyx_v_self); /*proto*/
4161 static void __pyx_pw_6ctabix_9Tabixfile_13__dealloc__(PyObject *__pyx_v_self) {
4162   __Pyx_RefNannyDeclarations
4163   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
4164   __pyx_pf_6ctabix_9Tabixfile_12__dealloc__(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self));
4165   __Pyx_RefNannyFinishContext();
4166 }
4167
4168 /* "ctabix.pyx":270
4169  *             self.tabixfile = NULL
4170  * 
4171  *     def __dealloc__( self ):             # <<<<<<<<<<<<<<
4172  *         # remember: dealloc cannot call other python methods
4173  *         # note: no doc string
4174  */
4175
4176 static void __pyx_pf_6ctabix_9Tabixfile_12__dealloc__(struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_self) {
4177   __Pyx_RefNannyDeclarations
4178   int __pyx_t_1;
4179   __Pyx_RefNannySetupContext("__dealloc__", 0);
4180
4181   /* "ctabix.pyx":274
4182  *         # note: no doc string
4183  *         # note: __del__ is not called.
4184  *         if self.tabixfile != NULL:             # <<<<<<<<<<<<<<
4185  *             ti_close( self.tabixfile )
4186  *             self.tabixfile = NULL
4187  */
4188   __pyx_t_1 = (__pyx_v_self->tabixfile != NULL);
4189   if (__pyx_t_1) {
4190
4191     /* "ctabix.pyx":275
4192  *         # note: __del__ is not called.
4193  *         if self.tabixfile != NULL:
4194  *             ti_close( self.tabixfile )             # <<<<<<<<<<<<<<
4195  *             self.tabixfile = NULL
4196  *         if self._filename != NULL: free( self._filename )
4197  */
4198     ti_close(__pyx_v_self->tabixfile);
4199
4200     /* "ctabix.pyx":276
4201  *         if self.tabixfile != NULL:
4202  *             ti_close( self.tabixfile )
4203  *             self.tabixfile = NULL             # <<<<<<<<<<<<<<
4204  *         if self._filename != NULL: free( self._filename )
4205  * 
4206  */
4207     __pyx_v_self->tabixfile = NULL;
4208     goto __pyx_L3;
4209   }
4210   __pyx_L3:;
4211
4212   /* "ctabix.pyx":277
4213  *             ti_close( self.tabixfile )
4214  *             self.tabixfile = NULL
4215  *         if self._filename != NULL: free( self._filename )             # <<<<<<<<<<<<<<
4216  * 
4217  * cdef class TabixIterator:
4218  */
4219   __pyx_t_1 = (__pyx_v_self->_filename != NULL);
4220   if (__pyx_t_1) {
4221     free(__pyx_v_self->_filename);
4222     goto __pyx_L4;
4223   }
4224   __pyx_L4:;
4225
4226   __Pyx_RefNannyFinishContext();
4227 }
4228
4229 /* Python wrapper */
4230 static int __pyx_pw_6ctabix_13TabixIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4231 static int __pyx_pw_6ctabix_13TabixIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4232   struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
4233   int __pyx_v_tid;
4234   int __pyx_v_start;
4235   int __pyx_v_end;
4236   int __pyx_r;
4237   __Pyx_RefNannyDeclarations
4238   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
4239   {
4240     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,0};
4241     PyObject* values[4] = {0,0,0,0};
4242     if (unlikely(__pyx_kwds)) {
4243       Py_ssize_t kw_args;
4244       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4245       switch (pos_args) {
4246         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4247         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4248         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4249         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4250         case  0: break;
4251         default: goto __pyx_L5_argtuple_error;
4252       }
4253       kw_args = PyDict_Size(__pyx_kwds);
4254       switch (pos_args) {
4255         case  0:
4256         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile)) != 0)) kw_args--;
4257         else goto __pyx_L5_argtuple_error;
4258         case  1:
4259         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid)) != 0)) kw_args--;
4260         else {
4261           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4262         }
4263         case  2:
4264         if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start)) != 0)) kw_args--;
4265         else {
4266           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4267         }
4268         case  3:
4269         if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--;
4270         else {
4271           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4272         }
4273       }
4274       if (unlikely(kw_args > 0)) {
4275         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4276       }
4277     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
4278       goto __pyx_L5_argtuple_error;
4279     } else {
4280       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4281       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4282       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4283       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4284     }
4285     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
4286     __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4287     __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4288     __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4289   }
4290   goto __pyx_L4_argument_unpacking_done;
4291   __pyx_L5_argtuple_error:;
4292   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4293   __pyx_L3_error:;
4294   __Pyx_AddTraceback("ctabix.TabixIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4295   __Pyx_RefNannyFinishContext();
4296   return -1;
4297   __pyx_L4_argument_unpacking_done:;
4298   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4299   __pyx_r = __pyx_pf_6ctabix_13TabixIterator___cinit__(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self), __pyx_v_tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end);
4300   goto __pyx_L0;
4301   __pyx_L1_error:;
4302   __pyx_r = -1;
4303   __pyx_L0:;
4304   __Pyx_RefNannyFinishContext();
4305   return __pyx_r;
4306 }
4307
4308 /* "ctabix.pyx":284
4309  *     """
4310  * 
4311  *     def __cinit__(self, Tabixfile tabixfile,             # <<<<<<<<<<<<<<
4312  *                   int tid, int start, int end ):
4313  * 
4314  */
4315
4316 static int __pyx_pf_6ctabix_13TabixIterator___cinit__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self, struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile, int __pyx_v_tid, int __pyx_v_start, int __pyx_v_end) {
4317   int __pyx_r;
4318   __Pyx_RefNannyDeclarations
4319   PyObject *__pyx_t_1 = NULL;
4320   PyObject *__pyx_t_2 = NULL;
4321   int __pyx_t_3;
4322   int __pyx_lineno = 0;
4323   const char *__pyx_filename = NULL;
4324   int __pyx_clineno = 0;
4325   __Pyx_RefNannySetupContext("__cinit__", 0);
4326
4327   /* "ctabix.pyx":287
4328  *                   int tid, int start, int end ):
4329  * 
4330  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
4331  * 
4332  *         # makes sure that samfile stays alive as long as the
4333  */
4334   #ifndef CYTHON_WITHOUT_ASSERTIONS
4335   __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 = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4336   __Pyx_GOTREF(__pyx_t_1);
4337   __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 = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4338   __Pyx_GOTREF(__pyx_t_2);
4339   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4340   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4341   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4342   if (unlikely(!__pyx_t_3)) {
4343     PyErr_SetNone(PyExc_AssertionError);
4344     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4345   }
4346   #endif
4347
4348   /* "ctabix.pyx":291
4349  *         # makes sure that samfile stays alive as long as the
4350  *         # iterator is alive.
4351  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
4352  * 
4353  *         if tid < 0:
4354  */
4355   __pyx_v_self->tabixfile = __pyx_v_tabixfile->tabixfile;
4356
4357   /* "ctabix.pyx":293
4358  *         self.tabixfile = tabixfile.tabixfile
4359  * 
4360  *         if tid < 0:             # <<<<<<<<<<<<<<
4361  *             # seek to start of file to ensure iteration is over
4362  *             # all entries.
4363  */
4364   __pyx_t_3 = (__pyx_v_tid < 0);
4365   if (__pyx_t_3) {
4366
4367     /* "ctabix.pyx":296
4368  *             # seek to start of file to ensure iteration is over
4369  *             # all entries.
4370  *             bgzf_seek( self.tabixfile.fp, 0, 0)             # <<<<<<<<<<<<<<
4371  *             self.iterator = ti_iter_first()
4372  *         else:
4373  */
4374     bgzf_seek(__pyx_v_self->tabixfile->fp, 0, 0);
4375
4376     /* "ctabix.pyx":297
4377  *             # all entries.
4378  *             bgzf_seek( self.tabixfile.fp, 0, 0)
4379  *             self.iterator = ti_iter_first()             # <<<<<<<<<<<<<<
4380  *         else:
4381  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
4382  */
4383     __pyx_v_self->iterator = ti_iter_first();
4384     goto __pyx_L3;
4385   }
4386   /*else*/ {
4387
4388     /* "ctabix.pyx":299
4389  *             self.iterator = ti_iter_first()
4390  *         else:
4391  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)             # <<<<<<<<<<<<<<
4392  * 
4393  *         if <void*>self.iterator == NULL:
4394  */
4395     __pyx_v_self->iterator = ti_queryi(__pyx_v_self->tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end);
4396   }
4397   __pyx_L3:;
4398
4399   /* "ctabix.pyx":301
4400  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
4401  * 
4402  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
4403  *             raise ValueError("malformatted query or wrong sequence name.\n")
4404  * 
4405  */
4406   __pyx_t_3 = (((void *)__pyx_v_self->iterator) == NULL);
4407   if (__pyx_t_3) {
4408
4409     /* "ctabix.pyx":302
4410  * 
4411  *         if <void*>self.iterator == NULL:
4412  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
4413  * 
4414  *     def __iter__(self):
4415  */
4416     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4417     __Pyx_GOTREF(__pyx_t_2);
4418     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
4419     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4420     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4421     goto __pyx_L4;
4422   }
4423   __pyx_L4:;
4424
4425   __pyx_r = 0;
4426   goto __pyx_L0;
4427   __pyx_L1_error:;
4428   __Pyx_XDECREF(__pyx_t_1);
4429   __Pyx_XDECREF(__pyx_t_2);
4430   __Pyx_AddTraceback("ctabix.TabixIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4431   __pyx_r = -1;
4432   __pyx_L0:;
4433   __Pyx_RefNannyFinishContext();
4434   return __pyx_r;
4435 }
4436
4437 /* Python wrapper */
4438 static PyObject *__pyx_pw_6ctabix_13TabixIterator_3__iter__(PyObject *__pyx_v_self); /*proto*/
4439 static PyObject *__pyx_pw_6ctabix_13TabixIterator_3__iter__(PyObject *__pyx_v_self) {
4440   PyObject *__pyx_r = 0;
4441   __Pyx_RefNannyDeclarations
4442   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
4443   __pyx_r = __pyx_pf_6ctabix_13TabixIterator_2__iter__(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self));
4444   __Pyx_RefNannyFinishContext();
4445   return __pyx_r;
4446 }
4447
4448 /* "ctabix.pyx":304
4449  *             raise ValueError("malformatted query or wrong sequence name.\n")
4450  * 
4451  *     def __iter__(self):             # <<<<<<<<<<<<<<
4452  *         return self
4453  * 
4454  */
4455
4456 static PyObject *__pyx_pf_6ctabix_13TabixIterator_2__iter__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self) {
4457   PyObject *__pyx_r = NULL;
4458   __Pyx_RefNannyDeclarations
4459   __Pyx_RefNannySetupContext("__iter__", 0);
4460
4461   /* "ctabix.pyx":305
4462  * 
4463  *     def __iter__(self):
4464  *         return self             # <<<<<<<<<<<<<<
4465  * 
4466  *     def __next__(self):
4467  */
4468   __Pyx_XDECREF(__pyx_r);
4469   __Pyx_INCREF(((PyObject *)__pyx_v_self));
4470   __pyx_r = ((PyObject *)__pyx_v_self);
4471   goto __pyx_L0;
4472
4473   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4474   __pyx_L0:;
4475   __Pyx_XGIVEREF(__pyx_r);
4476   __Pyx_RefNannyFinishContext();
4477   return __pyx_r;
4478 }
4479
4480 /* Python wrapper */
4481 static PyObject *__pyx_pw_6ctabix_13TabixIterator_5__next__(PyObject *__pyx_v_self); /*proto*/
4482 static char __pyx_doc_6ctabix_13TabixIterator_4__next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
4483 #if CYTHON_COMPILING_IN_CPYTHON
4484 struct wrapperbase __pyx_wrapperbase_6ctabix_13TabixIterator_4__next__;
4485 #endif
4486 static PyObject *__pyx_pw_6ctabix_13TabixIterator_5__next__(PyObject *__pyx_v_self) {
4487   PyObject *__pyx_r = 0;
4488   __Pyx_RefNannyDeclarations
4489   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
4490   __pyx_r = __pyx_pf_6ctabix_13TabixIterator_4__next__(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self));
4491   __Pyx_RefNannyFinishContext();
4492   return __pyx_r;
4493 }
4494
4495 /* "ctabix.pyx":307
4496  *         return self
4497  * 
4498  *     def __next__(self):             # <<<<<<<<<<<<<<
4499  *         """python version of next().
4500  * 
4501  */
4502
4503 static PyObject *__pyx_pf_6ctabix_13TabixIterator_4__next__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self) {
4504   char *__pyx_v_s;
4505   int __pyx_v_len;
4506   PyObject *__pyx_v_retval = NULL;
4507   PyObject *__pyx_r = NULL;
4508   __Pyx_RefNannyDeclarations
4509   int __pyx_t_1;
4510   PyObject *__pyx_t_2 = NULL;
4511   int __pyx_lineno = 0;
4512   const char *__pyx_filename = NULL;
4513   int __pyx_clineno = 0;
4514   __Pyx_RefNannySetupContext("__next__", 0);
4515
4516   /* "ctabix.pyx":320
4517  * 
4518  *         # simply use '#' for now.
4519  *         while 1:             # <<<<<<<<<<<<<<
4520  *             s = ti_read(self.tabixfile, self.iterator, &len)
4521  *             if s == NULL: raise StopIteration
4522  */
4523   while (1) {
4524     if (!1) break;
4525
4526     /* "ctabix.pyx":321
4527  *         # simply use '#' for now.
4528  *         while 1:
4529  *             s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
4530  *             if s == NULL: raise StopIteration
4531  *             if s[0] != '#': break
4532  */
4533     __pyx_v_s = ti_read(__pyx_v_self->tabixfile, __pyx_v_self->iterator, (&__pyx_v_len));
4534
4535     /* "ctabix.pyx":322
4536  *         while 1:
4537  *             s = ti_read(self.tabixfile, self.iterator, &len)
4538  *             if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
4539  *             if s[0] != '#': break
4540  * 
4541  */
4542     __pyx_t_1 = (__pyx_v_s == NULL);
4543     if (__pyx_t_1) {
4544       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
4545       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4546       goto __pyx_L5;
4547     }
4548     __pyx_L5:;
4549
4550     /* "ctabix.pyx":323
4551  *             s = ti_read(self.tabixfile, self.iterator, &len)
4552  *             if s == NULL: raise StopIteration
4553  *             if s[0] != '#': break             # <<<<<<<<<<<<<<
4554  * 
4555  *         retval = _charptr_to_str( s )
4556  */
4557     __pyx_t_1 = ((__pyx_v_s[0]) != '#');
4558     if (__pyx_t_1) {
4559       goto __pyx_L4_break;
4560       goto __pyx_L6;
4561     }
4562     __pyx_L6:;
4563   }
4564   __pyx_L4_break:;
4565
4566   /* "ctabix.pyx":325
4567  *             if s[0] != '#': break
4568  * 
4569  *         retval = _charptr_to_str( s )             # <<<<<<<<<<<<<<
4570  *         return retval
4571  * 
4572  */
4573   __pyx_t_2 = __pyx_f_6ctabix__charptr_to_str(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4574   __Pyx_GOTREF(__pyx_t_2);
4575   __pyx_v_retval = __pyx_t_2;
4576   __pyx_t_2 = 0;
4577
4578   /* "ctabix.pyx":326
4579  * 
4580  *         retval = _charptr_to_str( s )
4581  *         return retval             # <<<<<<<<<<<<<<
4582  * 
4583  *     def __dealloc__(self):
4584  */
4585   __Pyx_XDECREF(__pyx_r);
4586   __Pyx_INCREF(__pyx_v_retval);
4587   __pyx_r = __pyx_v_retval;
4588   goto __pyx_L0;
4589
4590   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4591   goto __pyx_L0;
4592   __pyx_L1_error:;
4593   __Pyx_XDECREF(__pyx_t_2);
4594   __Pyx_AddTraceback("ctabix.TabixIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4595   __pyx_r = NULL;
4596   __pyx_L0:;
4597   __Pyx_XDECREF(__pyx_v_retval);
4598   __Pyx_XGIVEREF(__pyx_r);
4599   __Pyx_RefNannyFinishContext();
4600   return __pyx_r;
4601 }
4602
4603 /* Python wrapper */
4604 static void __pyx_pw_6ctabix_13TabixIterator_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
4605 static void __pyx_pw_6ctabix_13TabixIterator_7__dealloc__(PyObject *__pyx_v_self) {
4606   __Pyx_RefNannyDeclarations
4607   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
4608   __pyx_pf_6ctabix_13TabixIterator_6__dealloc__(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self));
4609   __Pyx_RefNannyFinishContext();
4610 }
4611
4612 /* "ctabix.pyx":328
4613  *         return retval
4614  * 
4615  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
4616  *         if <void*>self.iterator != NULL:
4617  *             ti_iter_destroy(self.iterator)
4618  */
4619
4620 static void __pyx_pf_6ctabix_13TabixIterator_6__dealloc__(struct __pyx_obj_6ctabix_TabixIterator *__pyx_v_self) {
4621   __Pyx_RefNannyDeclarations
4622   int __pyx_t_1;
4623   __Pyx_RefNannySetupContext("__dealloc__", 0);
4624
4625   /* "ctabix.pyx":329
4626  * 
4627  *     def __dealloc__(self):
4628  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
4629  *             ti_iter_destroy(self.iterator)
4630  * 
4631  */
4632   __pyx_t_1 = (((void *)__pyx_v_self->iterator) != NULL);
4633   if (__pyx_t_1) {
4634
4635     /* "ctabix.pyx":330
4636  *     def __dealloc__(self):
4637  *         if <void*>self.iterator != NULL:
4638  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
4639  * 
4640  * cdef class TabixHeaderIterator:
4641  */
4642     ti_iter_destroy(__pyx_v_self->iterator);
4643     goto __pyx_L3;
4644   }
4645   __pyx_L3:;
4646
4647   __Pyx_RefNannyFinishContext();
4648 }
4649
4650 /* Python wrapper */
4651 static int __pyx_pw_6ctabix_19TabixHeaderIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4652 static int __pyx_pw_6ctabix_19TabixHeaderIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4653   struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
4654   int __pyx_r;
4655   __Pyx_RefNannyDeclarations
4656   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
4657   {
4658     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,0};
4659     PyObject* values[1] = {0};
4660     if (unlikely(__pyx_kwds)) {
4661       Py_ssize_t kw_args;
4662       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4663       switch (pos_args) {
4664         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4665         case  0: break;
4666         default: goto __pyx_L5_argtuple_error;
4667       }
4668       kw_args = PyDict_Size(__pyx_kwds);
4669       switch (pos_args) {
4670         case  0:
4671         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile)) != 0)) kw_args--;
4672         else goto __pyx_L5_argtuple_error;
4673       }
4674       if (unlikely(kw_args > 0)) {
4675         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4676       }
4677     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
4678       goto __pyx_L5_argtuple_error;
4679     } else {
4680       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4681     }
4682     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
4683   }
4684   goto __pyx_L4_argument_unpacking_done;
4685   __pyx_L5_argtuple_error:;
4686   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4687   __pyx_L3_error:;
4688   __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4689   __Pyx_RefNannyFinishContext();
4690   return -1;
4691   __pyx_L4_argument_unpacking_done:;
4692   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4693   __pyx_r = __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self), __pyx_v_tabixfile);
4694   goto __pyx_L0;
4695   __pyx_L1_error:;
4696   __pyx_r = -1;
4697   __pyx_L0:;
4698   __Pyx_RefNannyFinishContext();
4699   return __pyx_r;
4700 }
4701
4702 /* "ctabix.pyx":336
4703  *     """
4704  * 
4705  *     def __cinit__(self, Tabixfile tabixfile ):             # <<<<<<<<<<<<<<
4706  * 
4707  *         assert tabixfile._isOpen()
4708  */
4709
4710 static int __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self, struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile) {
4711   int __pyx_r;
4712   __Pyx_RefNannyDeclarations
4713   PyObject *__pyx_t_1 = NULL;
4714   PyObject *__pyx_t_2 = NULL;
4715   int __pyx_t_3;
4716   int __pyx_lineno = 0;
4717   const char *__pyx_filename = NULL;
4718   int __pyx_clineno = 0;
4719   __Pyx_RefNannySetupContext("__cinit__", 0);
4720
4721   /* "ctabix.pyx":338
4722  *     def __cinit__(self, Tabixfile tabixfile ):
4723  * 
4724  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
4725  * 
4726  *         # makes sure that samfile stays alive as long as the
4727  */
4728   #ifndef CYTHON_WITHOUT_ASSERTIONS
4729   __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 = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4730   __Pyx_GOTREF(__pyx_t_1);
4731   __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 = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4732   __Pyx_GOTREF(__pyx_t_2);
4733   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4734   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4735   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4736   if (unlikely(!__pyx_t_3)) {
4737     PyErr_SetNone(PyExc_AssertionError);
4738     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4739   }
4740   #endif
4741
4742   /* "ctabix.pyx":342
4743  *         # makes sure that samfile stays alive as long as the
4744  *         # iterator is alive.
4745  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
4746  * 
4747  *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)
4748  */
4749   __pyx_v_self->tabixfile = __pyx_v_tabixfile->tabixfile;
4750
4751   /* "ctabix.pyx":344
4752  *         self.tabixfile = tabixfile.tabixfile
4753  * 
4754  *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)             # <<<<<<<<<<<<<<
4755  * 
4756  *         if <void*>self.iterator == NULL:
4757  */
4758   __pyx_v_self->iterator = ti_query(__pyx_v_self->tabixfile, NULL, 0, 0);
4759
4760   /* "ctabix.pyx":346
4761  *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)
4762  * 
4763  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
4764  *             raise ValueError("can't open header.\n")
4765  * 
4766  */
4767   __pyx_t_3 = (((void *)__pyx_v_self->iterator) == NULL);
4768   if (__pyx_t_3) {
4769
4770     /* "ctabix.pyx":347
4771  * 
4772  *         if <void*>self.iterator == NULL:
4773  *             raise ValueError("can't open header.\n")             # <<<<<<<<<<<<<<
4774  * 
4775  *     def __iter__(self):
4776  */
4777     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_28), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4778     __Pyx_GOTREF(__pyx_t_2);
4779     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
4780     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4781     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4782     goto __pyx_L3;
4783   }
4784   __pyx_L3:;
4785
4786   __pyx_r = 0;
4787   goto __pyx_L0;
4788   __pyx_L1_error:;
4789   __Pyx_XDECREF(__pyx_t_1);
4790   __Pyx_XDECREF(__pyx_t_2);
4791   __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4792   __pyx_r = -1;
4793   __pyx_L0:;
4794   __Pyx_RefNannyFinishContext();
4795   return __pyx_r;
4796 }
4797
4798 /* Python wrapper */
4799 static PyObject *__pyx_pw_6ctabix_19TabixHeaderIterator_3__iter__(PyObject *__pyx_v_self); /*proto*/
4800 static PyObject *__pyx_pw_6ctabix_19TabixHeaderIterator_3__iter__(PyObject *__pyx_v_self) {
4801   PyObject *__pyx_r = 0;
4802   __Pyx_RefNannyDeclarations
4803   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
4804   __pyx_r = __pyx_pf_6ctabix_19TabixHeaderIterator_2__iter__(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self));
4805   __Pyx_RefNannyFinishContext();
4806   return __pyx_r;
4807 }
4808
4809 /* "ctabix.pyx":349
4810  *             raise ValueError("can't open header.\n")
4811  * 
4812  *     def __iter__(self):             # <<<<<<<<<<<<<<
4813  *         return self
4814  * 
4815  */
4816
4817 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator_2__iter__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self) {
4818   PyObject *__pyx_r = NULL;
4819   __Pyx_RefNannyDeclarations
4820   __Pyx_RefNannySetupContext("__iter__", 0);
4821
4822   /* "ctabix.pyx":350
4823  * 
4824  *     def __iter__(self):
4825  *         return self             # <<<<<<<<<<<<<<
4826  * 
4827  *     def __next__(self):
4828  */
4829   __Pyx_XDECREF(__pyx_r);
4830   __Pyx_INCREF(((PyObject *)__pyx_v_self));
4831   __pyx_r = ((PyObject *)__pyx_v_self);
4832   goto __pyx_L0;
4833
4834   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4835   __pyx_L0:;
4836   __Pyx_XGIVEREF(__pyx_r);
4837   __Pyx_RefNannyFinishContext();
4838   return __pyx_r;
4839 }
4840
4841 /* Python wrapper */
4842 static PyObject *__pyx_pw_6ctabix_19TabixHeaderIterator_5__next__(PyObject *__pyx_v_self); /*proto*/
4843 static char __pyx_doc_6ctabix_19TabixHeaderIterator_4__next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
4844 #if CYTHON_COMPILING_IN_CPYTHON
4845 struct wrapperbase __pyx_wrapperbase_6ctabix_19TabixHeaderIterator_4__next__;
4846 #endif
4847 static PyObject *__pyx_pw_6ctabix_19TabixHeaderIterator_5__next__(PyObject *__pyx_v_self) {
4848   PyObject *__pyx_r = 0;
4849   __Pyx_RefNannyDeclarations
4850   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
4851   __pyx_r = __pyx_pf_6ctabix_19TabixHeaderIterator_4__next__(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self));
4852   __Pyx_RefNannyFinishContext();
4853   return __pyx_r;
4854 }
4855
4856 /* "ctabix.pyx":352
4857  *         return self
4858  * 
4859  *     def __next__(self):             # <<<<<<<<<<<<<<
4860  *         """python version of next().
4861  * 
4862  */
4863
4864 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator_4__next__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self) {
4865   char *__pyx_v_s;
4866   int __pyx_v_len;
4867   PyObject *__pyx_r = NULL;
4868   __Pyx_RefNannyDeclarations
4869   int __pyx_t_1;
4870   PyObject *__pyx_t_2 = NULL;
4871   int __pyx_lineno = 0;
4872   const char *__pyx_filename = NULL;
4873   int __pyx_clineno = 0;
4874   __Pyx_RefNannySetupContext("__next__", 0);
4875
4876   /* "ctabix.pyx":363
4877  *         # Getting the metachar is a pain as ti_index_t is incomplete type.
4878  *         # simply use '#' for now.
4879  *         s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
4880  *         if s == NULL: raise StopIteration
4881  *         # stop at first non-header line
4882  */
4883   __pyx_v_s = ti_read(__pyx_v_self->tabixfile, __pyx_v_self->iterator, (&__pyx_v_len));
4884
4885   /* "ctabix.pyx":364
4886  *         # simply use '#' for now.
4887  *         s = ti_read(self.tabixfile, self.iterator, &len)
4888  *         if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
4889  *         # stop at first non-header line
4890  *         if s[0] != '#': raise StopIteration
4891  */
4892   __pyx_t_1 = (__pyx_v_s == NULL);
4893   if (__pyx_t_1) {
4894     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
4895     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4896     goto __pyx_L3;
4897   }
4898   __pyx_L3:;
4899
4900   /* "ctabix.pyx":366
4901  *         if s == NULL: raise StopIteration
4902  *         # stop at first non-header line
4903  *         if s[0] != '#': raise StopIteration             # <<<<<<<<<<<<<<
4904  * 
4905  *         return s
4906  */
4907   __pyx_t_1 = ((__pyx_v_s[0]) != '#');
4908   if (__pyx_t_1) {
4909     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
4910     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4911     goto __pyx_L4;
4912   }
4913   __pyx_L4:;
4914
4915   /* "ctabix.pyx":368
4916  *         if s[0] != '#': raise StopIteration
4917  * 
4918  *         return s             # <<<<<<<<<<<<<<
4919  * 
4920  *     def __dealloc__(self):
4921  */
4922   __Pyx_XDECREF(__pyx_r);
4923   __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4924   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
4925   __pyx_r = ((PyObject *)__pyx_t_2);
4926   __pyx_t_2 = 0;
4927   goto __pyx_L0;
4928
4929   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4930   goto __pyx_L0;
4931   __pyx_L1_error:;
4932   __Pyx_XDECREF(__pyx_t_2);
4933   __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4934   __pyx_r = NULL;
4935   __pyx_L0:;
4936   __Pyx_XGIVEREF(__pyx_r);
4937   __Pyx_RefNannyFinishContext();
4938   return __pyx_r;
4939 }
4940
4941 /* Python wrapper */
4942 static void __pyx_pw_6ctabix_19TabixHeaderIterator_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
4943 static void __pyx_pw_6ctabix_19TabixHeaderIterator_7__dealloc__(PyObject *__pyx_v_self) {
4944   __Pyx_RefNannyDeclarations
4945   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
4946   __pyx_pf_6ctabix_19TabixHeaderIterator_6__dealloc__(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self));
4947   __Pyx_RefNannyFinishContext();
4948 }
4949
4950 /* "ctabix.pyx":370
4951  *         return s
4952  * 
4953  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
4954  *         if <void*>self.iterator != NULL:
4955  *             ti_iter_destroy(self.iterator)
4956  */
4957
4958 static void __pyx_pf_6ctabix_19TabixHeaderIterator_6__dealloc__(struct __pyx_obj_6ctabix_TabixHeaderIterator *__pyx_v_self) {
4959   __Pyx_RefNannyDeclarations
4960   int __pyx_t_1;
4961   __Pyx_RefNannySetupContext("__dealloc__", 0);
4962
4963   /* "ctabix.pyx":371
4964  * 
4965  *     def __dealloc__(self):
4966  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
4967  *             ti_iter_destroy(self.iterator)
4968  * 
4969  */
4970   __pyx_t_1 = (((void *)__pyx_v_self->iterator) != NULL);
4971   if (__pyx_t_1) {
4972
4973     /* "ctabix.pyx":372
4974  *     def __dealloc__(self):
4975  *         if <void*>self.iterator != NULL:
4976  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
4977  * 
4978  * 
4979  */
4980     ti_iter_destroy(__pyx_v_self->iterator);
4981     goto __pyx_L3;
4982   }
4983   __pyx_L3:;
4984
4985   __Pyx_RefNannyFinishContext();
4986 }
4987
4988 /* Python wrapper */
4989 static PyObject *__pyx_pw_6ctabix_7asTuple_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4990 static PyObject *__pyx_pw_6ctabix_7asTuple_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4991   char *__pyx_v_buffer;
4992   int __pyx_v_len;
4993   PyObject *__pyx_r = 0;
4994   __Pyx_RefNannyDeclarations
4995   __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
4996   {
4997     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
4998     PyObject* values[2] = {0,0};
4999     if (unlikely(__pyx_kwds)) {
5000       Py_ssize_t kw_args;
5001       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5002       switch (pos_args) {
5003         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5004         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5005         case  0: break;
5006         default: goto __pyx_L5_argtuple_error;
5007       }
5008       kw_args = PyDict_Size(__pyx_kwds);
5009       switch (pos_args) {
5010         case  0:
5011         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer)) != 0)) kw_args--;
5012         else goto __pyx_L5_argtuple_error;
5013         case  1:
5014         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len)) != 0)) kw_args--;
5015         else {
5016           __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5017         }
5018       }
5019       if (unlikely(kw_args > 0)) {
5020         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5021       }
5022     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5023       goto __pyx_L5_argtuple_error;
5024     } else {
5025       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5026       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5027     }
5028     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5029     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5030   }
5031   goto __pyx_L4_argument_unpacking_done;
5032   __pyx_L5_argtuple_error:;
5033   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5034   __pyx_L3_error:;
5035   __Pyx_AddTraceback("ctabix.asTuple.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5036   __Pyx_RefNannyFinishContext();
5037   return NULL;
5038   __pyx_L4_argument_unpacking_done:;
5039   __pyx_r = __pyx_pf_6ctabix_7asTuple___call__(((struct __pyx_obj_6ctabix_asTuple *)__pyx_v_self), __pyx_v_buffer, __pyx_v_len);
5040   __Pyx_RefNannyFinishContext();
5041   return __pyx_r;
5042 }
5043
5044 /* "ctabix.pyx":386
5045  *     Access is by numeric index.
5046  *     '''
5047  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
5048  *         cdef TabProxies.TupleProxy r
5049  *         r = TabProxies.TupleProxy()
5050  */
5051
5052 static PyObject *__pyx_pf_6ctabix_7asTuple___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asTuple *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len) {
5053   struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_r = 0;
5054   PyObject *__pyx_r = NULL;
5055   __Pyx_RefNannyDeclarations
5056   PyObject *__pyx_t_1 = NULL;
5057   int __pyx_lineno = 0;
5058   const char *__pyx_filename = NULL;
5059   int __pyx_clineno = 0;
5060   __Pyx_RefNannySetupContext("__call__", 0);
5061
5062   /* "ctabix.pyx":388
5063  *     def __call__(self, char * buffer, int len):
5064  *         cdef TabProxies.TupleProxy r
5065  *         r = TabProxies.TupleProxy()             # <<<<<<<<<<<<<<
5066  *         # need to copy - there were some
5067  *         # persistence issues with "present"
5068  */
5069   __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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5070   __Pyx_GOTREF(__pyx_t_1);
5071   __pyx_v_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_t_1);
5072   __pyx_t_1 = 0;
5073
5074   /* "ctabix.pyx":391
5075  *         # need to copy - there were some
5076  *         # persistence issues with "present"
5077  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
5078  *         return r
5079  * 
5080  */
5081   __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 = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5082   __Pyx_GOTREF(__pyx_t_1);
5083   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5084
5085   /* "ctabix.pyx":392
5086  *         # persistence issues with "present"
5087  *         r.copy( buffer, len )
5088  *         return r             # <<<<<<<<<<<<<<
5089  * 
5090  * cdef class asGTF(Parser):
5091  */
5092   __Pyx_XDECREF(__pyx_r);
5093   __Pyx_INCREF(((PyObject *)__pyx_v_r));
5094   __pyx_r = ((PyObject *)__pyx_v_r);
5095   goto __pyx_L0;
5096
5097   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5098   goto __pyx_L0;
5099   __pyx_L1_error:;
5100   __Pyx_XDECREF(__pyx_t_1);
5101   __Pyx_AddTraceback("ctabix.asTuple.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5102   __pyx_r = NULL;
5103   __pyx_L0:;
5104   __Pyx_XDECREF((PyObject *)__pyx_v_r);
5105   __Pyx_XGIVEREF(__pyx_r);
5106   __Pyx_RefNannyFinishContext();
5107   return __pyx_r;
5108 }
5109
5110 /* Python wrapper */
5111 static PyObject *__pyx_pw_6ctabix_5asGTF_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5112 static PyObject *__pyx_pw_6ctabix_5asGTF_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5113   char *__pyx_v_buffer;
5114   int __pyx_v_len;
5115   PyObject *__pyx_r = 0;
5116   __Pyx_RefNannyDeclarations
5117   __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
5118   {
5119     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
5120     PyObject* values[2] = {0,0};
5121     if (unlikely(__pyx_kwds)) {
5122       Py_ssize_t kw_args;
5123       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5124       switch (pos_args) {
5125         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5126         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5127         case  0: break;
5128         default: goto __pyx_L5_argtuple_error;
5129       }
5130       kw_args = PyDict_Size(__pyx_kwds);
5131       switch (pos_args) {
5132         case  0:
5133         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer)) != 0)) kw_args--;
5134         else goto __pyx_L5_argtuple_error;
5135         case  1:
5136         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len)) != 0)) kw_args--;
5137         else {
5138           __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5139         }
5140       }
5141       if (unlikely(kw_args > 0)) {
5142         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5143       }
5144     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5145       goto __pyx_L5_argtuple_error;
5146     } else {
5147       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5148       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5149     }
5150     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5151     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5152   }
5153   goto __pyx_L4_argument_unpacking_done;
5154   __pyx_L5_argtuple_error:;
5155   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5156   __pyx_L3_error:;
5157   __Pyx_AddTraceback("ctabix.asGTF.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5158   __Pyx_RefNannyFinishContext();
5159   return NULL;
5160   __pyx_L4_argument_unpacking_done:;
5161   __pyx_r = __pyx_pf_6ctabix_5asGTF___call__(((struct __pyx_obj_6ctabix_asGTF *)__pyx_v_self), __pyx_v_buffer, __pyx_v_len);
5162   __Pyx_RefNannyFinishContext();
5163   return __pyx_r;
5164 }
5165
5166 /* "ctabix.pyx":425
5167  * 
5168  *     '''
5169  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
5170  *         cdef TabProxies.GTFProxy r
5171  *         r = TabProxies.GTFProxy()
5172  */
5173
5174 static PyObject *__pyx_pf_6ctabix_5asGTF___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asGTF *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len) {
5175   struct __pyx_obj_10TabProxies_GTFProxy *__pyx_v_r = 0;
5176   PyObject *__pyx_r = NULL;
5177   __Pyx_RefNannyDeclarations
5178   PyObject *__pyx_t_1 = NULL;
5179   int __pyx_lineno = 0;
5180   const char *__pyx_filename = NULL;
5181   int __pyx_clineno = 0;
5182   __Pyx_RefNannySetupContext("__call__", 0);
5183
5184   /* "ctabix.pyx":427
5185  *     def __call__(self, char * buffer, int len):
5186  *         cdef TabProxies.GTFProxy r
5187  *         r = TabProxies.GTFProxy()             # <<<<<<<<<<<<<<
5188  *         r.copy( buffer, len )
5189  *         return r
5190  */
5191   __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 = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5192   __Pyx_GOTREF(__pyx_t_1);
5193   __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_t_1);
5194   __pyx_t_1 = 0;
5195
5196   /* "ctabix.pyx":428
5197  *         cdef TabProxies.GTFProxy r
5198  *         r = TabProxies.GTFProxy()
5199  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
5200  *         return r
5201  * 
5202  */
5203   __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 = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5204   __Pyx_GOTREF(__pyx_t_1);
5205   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5206
5207   /* "ctabix.pyx":429
5208  *         r = TabProxies.GTFProxy()
5209  *         r.copy( buffer, len )
5210  *         return r             # <<<<<<<<<<<<<<
5211  * 
5212  * cdef class asBed( Parser ):
5213  */
5214   __Pyx_XDECREF(__pyx_r);
5215   __Pyx_INCREF(((PyObject *)__pyx_v_r));
5216   __pyx_r = ((PyObject *)__pyx_v_r);
5217   goto __pyx_L0;
5218
5219   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5220   goto __pyx_L0;
5221   __pyx_L1_error:;
5222   __Pyx_XDECREF(__pyx_t_1);
5223   __Pyx_AddTraceback("ctabix.asGTF.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5224   __pyx_r = NULL;
5225   __pyx_L0:;
5226   __Pyx_XDECREF((PyObject *)__pyx_v_r);
5227   __Pyx_XGIVEREF(__pyx_r);
5228   __Pyx_RefNannyFinishContext();
5229   return __pyx_r;
5230 }
5231
5232 /* Python wrapper */
5233 static PyObject *__pyx_pw_6ctabix_5asBed_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5234 static PyObject *__pyx_pw_6ctabix_5asBed_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5235   char *__pyx_v_buffer;
5236   int __pyx_v_len;
5237   PyObject *__pyx_r = 0;
5238   __Pyx_RefNannyDeclarations
5239   __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
5240   {
5241     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
5242     PyObject* values[2] = {0,0};
5243     if (unlikely(__pyx_kwds)) {
5244       Py_ssize_t kw_args;
5245       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5246       switch (pos_args) {
5247         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5248         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5249         case  0: break;
5250         default: goto __pyx_L5_argtuple_error;
5251       }
5252       kw_args = PyDict_Size(__pyx_kwds);
5253       switch (pos_args) {
5254         case  0:
5255         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer)) != 0)) kw_args--;
5256         else goto __pyx_L5_argtuple_error;
5257         case  1:
5258         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len)) != 0)) kw_args--;
5259         else {
5260           __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5261         }
5262       }
5263       if (unlikely(kw_args > 0)) {
5264         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5265       }
5266     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5267       goto __pyx_L5_argtuple_error;
5268     } else {
5269       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5270       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5271     }
5272     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5273     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5274   }
5275   goto __pyx_L4_argument_unpacking_done;
5276   __pyx_L5_argtuple_error:;
5277   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5278   __pyx_L3_error:;
5279   __Pyx_AddTraceback("ctabix.asBed.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5280   __Pyx_RefNannyFinishContext();
5281   return NULL;
5282   __pyx_L4_argument_unpacking_done:;
5283   __pyx_r = __pyx_pf_6ctabix_5asBed___call__(((struct __pyx_obj_6ctabix_asBed *)__pyx_v_self), __pyx_v_buffer, __pyx_v_len);
5284   __Pyx_RefNannyFinishContext();
5285   return __pyx_r;
5286 }
5287
5288 /* "ctabix.pyx":465
5289  * 
5290  *     '''
5291  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
5292  *         cdef TabProxies.BedProxy r
5293  *         r = TabProxies.BedProxy()
5294  */
5295
5296 static PyObject *__pyx_pf_6ctabix_5asBed___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asBed *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len) {
5297   struct __pyx_obj_10TabProxies_BedProxy *__pyx_v_r = 0;
5298   PyObject *__pyx_r = NULL;
5299   __Pyx_RefNannyDeclarations
5300   PyObject *__pyx_t_1 = NULL;
5301   int __pyx_lineno = 0;
5302   const char *__pyx_filename = NULL;
5303   int __pyx_clineno = 0;
5304   __Pyx_RefNannySetupContext("__call__", 0);
5305
5306   /* "ctabix.pyx":467
5307  *     def __call__(self, char * buffer, int len):
5308  *         cdef TabProxies.BedProxy r
5309  *         r = TabProxies.BedProxy()             # <<<<<<<<<<<<<<
5310  *         r.copy( buffer, len )
5311  *         return r
5312  */
5313   __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 = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5314   __Pyx_GOTREF(__pyx_t_1);
5315   __pyx_v_r = ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_t_1);
5316   __pyx_t_1 = 0;
5317
5318   /* "ctabix.pyx":468
5319  *         cdef TabProxies.BedProxy r
5320  *         r = TabProxies.BedProxy()
5321  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
5322  *         return r
5323  * 
5324  */
5325   __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 = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5326   __Pyx_GOTREF(__pyx_t_1);
5327   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5328
5329   /* "ctabix.pyx":469
5330  *         r = TabProxies.BedProxy()
5331  *         r.copy( buffer, len )
5332  *         return r             # <<<<<<<<<<<<<<
5333  * 
5334  * cdef class asVCF( Parser ):
5335  */
5336   __Pyx_XDECREF(__pyx_r);
5337   __Pyx_INCREF(((PyObject *)__pyx_v_r));
5338   __pyx_r = ((PyObject *)__pyx_v_r);
5339   goto __pyx_L0;
5340
5341   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5342   goto __pyx_L0;
5343   __pyx_L1_error:;
5344   __Pyx_XDECREF(__pyx_t_1);
5345   __Pyx_AddTraceback("ctabix.asBed.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5346   __pyx_r = NULL;
5347   __pyx_L0:;
5348   __Pyx_XDECREF((PyObject *)__pyx_v_r);
5349   __Pyx_XGIVEREF(__pyx_r);
5350   __Pyx_RefNannyFinishContext();
5351   return __pyx_r;
5352 }
5353
5354 /* Python wrapper */
5355 static PyObject *__pyx_pw_6ctabix_5asVCF_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5356 static PyObject *__pyx_pw_6ctabix_5asVCF_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5357   char *__pyx_v_buffer;
5358   int __pyx_v_len;
5359   PyObject *__pyx_r = 0;
5360   __Pyx_RefNannyDeclarations
5361   __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
5362   {
5363     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
5364     PyObject* values[2] = {0,0};
5365     if (unlikely(__pyx_kwds)) {
5366       Py_ssize_t kw_args;
5367       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5368       switch (pos_args) {
5369         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5370         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5371         case  0: break;
5372         default: goto __pyx_L5_argtuple_error;
5373       }
5374       kw_args = PyDict_Size(__pyx_kwds);
5375       switch (pos_args) {
5376         case  0:
5377         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer)) != 0)) kw_args--;
5378         else goto __pyx_L5_argtuple_error;
5379         case  1:
5380         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len)) != 0)) kw_args--;
5381         else {
5382           __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5383         }
5384       }
5385       if (unlikely(kw_args > 0)) {
5386         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5387       }
5388     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5389       goto __pyx_L5_argtuple_error;
5390     } else {
5391       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5392       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5393     }
5394     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5395     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5396   }
5397   goto __pyx_L4_argument_unpacking_done;
5398   __pyx_L5_argtuple_error:;
5399   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5400   __pyx_L3_error:;
5401   __Pyx_AddTraceback("ctabix.asVCF.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5402   __Pyx_RefNannyFinishContext();
5403   return NULL;
5404   __pyx_L4_argument_unpacking_done:;
5405   __pyx_r = __pyx_pf_6ctabix_5asVCF___call__(((struct __pyx_obj_6ctabix_asVCF *)__pyx_v_self), __pyx_v_buffer, __pyx_v_len);
5406   __Pyx_RefNannyFinishContext();
5407   return __pyx_r;
5408 }
5409
5410 /* "ctabix.pyx":501
5411  * 
5412  *     '''
5413  *     def __call__(self, char * buffer, int len ):             # <<<<<<<<<<<<<<
5414  *         cdef TabProxies.VCFProxy r
5415  *         r = TabProxies.VCFProxy()
5416  */
5417
5418 static PyObject *__pyx_pf_6ctabix_5asVCF___call__(CYTHON_UNUSED struct __pyx_obj_6ctabix_asVCF *__pyx_v_self, char *__pyx_v_buffer, int __pyx_v_len) {
5419   struct __pyx_obj_10TabProxies_VCFProxy *__pyx_v_r = 0;
5420   PyObject *__pyx_r = NULL;
5421   __Pyx_RefNannyDeclarations
5422   PyObject *__pyx_t_1 = NULL;
5423   int __pyx_lineno = 0;
5424   const char *__pyx_filename = NULL;
5425   int __pyx_clineno = 0;
5426   __Pyx_RefNannySetupContext("__call__", 0);
5427
5428   /* "ctabix.pyx":503
5429  *     def __call__(self, char * buffer, int len ):
5430  *         cdef TabProxies.VCFProxy r
5431  *         r = TabProxies.VCFProxy()             # <<<<<<<<<<<<<<
5432  *         r.copy( buffer, len )
5433  *         return r
5434  */
5435   __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 = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5436   __Pyx_GOTREF(__pyx_t_1);
5437   __pyx_v_r = ((struct __pyx_obj_10TabProxies_VCFProxy *)__pyx_t_1);
5438   __pyx_t_1 = 0;
5439
5440   /* "ctabix.pyx":504
5441  *         cdef TabProxies.VCFProxy r
5442  *         r = TabProxies.VCFProxy()
5443  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
5444  *         return r
5445  * 
5446  */
5447   __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 = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5448   __Pyx_GOTREF(__pyx_t_1);
5449   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5450
5451   /* "ctabix.pyx":505
5452  *         r = TabProxies.VCFProxy()
5453  *         r.copy( buffer, len )
5454  *         return r             # <<<<<<<<<<<<<<
5455  * 
5456  * #########################################################
5457  */
5458   __Pyx_XDECREF(__pyx_r);
5459   __Pyx_INCREF(((PyObject *)__pyx_v_r));
5460   __pyx_r = ((PyObject *)__pyx_v_r);
5461   goto __pyx_L0;
5462
5463   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5464   goto __pyx_L0;
5465   __pyx_L1_error:;
5466   __Pyx_XDECREF(__pyx_t_1);
5467   __Pyx_AddTraceback("ctabix.asVCF.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5468   __pyx_r = NULL;
5469   __pyx_L0:;
5470   __Pyx_XDECREF((PyObject *)__pyx_v_r);
5471   __Pyx_XGIVEREF(__pyx_r);
5472   __Pyx_RefNannyFinishContext();
5473   return __pyx_r;
5474 }
5475
5476 /* Python wrapper */
5477 static int __pyx_pw_6ctabix_19TabixIteratorParsed_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5478 static int __pyx_pw_6ctabix_19TabixIteratorParsed_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5479   struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
5480   int __pyx_v_tid;
5481   int __pyx_v_start;
5482   int __pyx_v_end;
5483   struct __pyx_obj_6ctabix_Parser *__pyx_v_parser = 0;
5484   int __pyx_r;
5485   __Pyx_RefNannyDeclarations
5486   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
5487   {
5488     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};
5489     PyObject* values[5] = {0,0,0,0,0};
5490     if (unlikely(__pyx_kwds)) {
5491       Py_ssize_t kw_args;
5492       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5493       switch (pos_args) {
5494         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5495         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5496         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5497         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5498         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5499         case  0: break;
5500         default: goto __pyx_L5_argtuple_error;
5501       }
5502       kw_args = PyDict_Size(__pyx_kwds);
5503       switch (pos_args) {
5504         case  0:
5505         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile)) != 0)) kw_args--;
5506         else goto __pyx_L5_argtuple_error;
5507         case  1:
5508         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid)) != 0)) kw_args--;
5509         else {
5510           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5511         }
5512         case  2:
5513         if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start)) != 0)) kw_args--;
5514         else {
5515           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5516         }
5517         case  3:
5518         if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--;
5519         else {
5520           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5521         }
5522         case  4:
5523         if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser)) != 0)) kw_args--;
5524         else {
5525           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5526         }
5527       }
5528       if (unlikely(kw_args > 0)) {
5529         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5530       }
5531     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
5532       goto __pyx_L5_argtuple_error;
5533     } else {
5534       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5535       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5536       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5537       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5538       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5539     }
5540     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
5541     __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5542     __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5543     __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5544     __pyx_v_parser = ((struct __pyx_obj_6ctabix_Parser *)values[4]);
5545   }
5546   goto __pyx_L4_argument_unpacking_done;
5547   __pyx_L5_argtuple_error:;
5548   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5549   __pyx_L3_error:;
5550   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5551   __Pyx_RefNannyFinishContext();
5552   return -1;
5553   __pyx_L4_argument_unpacking_done:;
5554   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5555   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_6ctabix_Parser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5556   __pyx_r = __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self), __pyx_v_tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end, __pyx_v_parser);
5557   goto __pyx_L0;
5558   __pyx_L1_error:;
5559   __pyx_r = -1;
5560   __pyx_L0:;
5561   __Pyx_RefNannyFinishContext();
5562   return __pyx_r;
5563 }
5564
5565 /* "ctabix.pyx":516
5566  *     """
5567  * 
5568  *     def __cinit__(self,             # <<<<<<<<<<<<<<
5569  *                   Tabixfile tabixfile,
5570  *                   int tid,
5571  */
5572
5573 static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self, struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile, int __pyx_v_tid, int __pyx_v_start, int __pyx_v_end, struct __pyx_obj_6ctabix_Parser *__pyx_v_parser) {
5574   int __pyx_r;
5575   __Pyx_RefNannyDeclarations
5576   PyObject *__pyx_t_1 = NULL;
5577   PyObject *__pyx_t_2 = NULL;
5578   int __pyx_t_3;
5579   int __pyx_lineno = 0;
5580   const char *__pyx_filename = NULL;
5581   int __pyx_clineno = 0;
5582   __Pyx_RefNannySetupContext("__cinit__", 0);
5583
5584   /* "ctabix.pyx":523
5585  *                   Parser parser ):
5586  * 
5587  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
5588  *         self.parser = parser
5589  * 
5590  */
5591   #ifndef CYTHON_WITHOUT_ASSERTIONS
5592   __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 = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5593   __Pyx_GOTREF(__pyx_t_1);
5594   __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 = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5595   __Pyx_GOTREF(__pyx_t_2);
5596   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5597   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5598   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5599   if (unlikely(!__pyx_t_3)) {
5600     PyErr_SetNone(PyExc_AssertionError);
5601     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5602   }
5603   #endif
5604
5605   /* "ctabix.pyx":524
5606  * 
5607  *         assert tabixfile._isOpen()
5608  *         self.parser = parser             # <<<<<<<<<<<<<<
5609  * 
5610  *         # makes sure that samfile stays alive as long as the
5611  */
5612   __Pyx_INCREF(((PyObject *)__pyx_v_parser));
5613   __Pyx_GIVEREF(((PyObject *)__pyx_v_parser));
5614   __Pyx_GOTREF(__pyx_v_self->parser);
5615   __Pyx_DECREF(((PyObject *)__pyx_v_self->parser));
5616   __pyx_v_self->parser = __pyx_v_parser;
5617
5618   /* "ctabix.pyx":528
5619  *         # makes sure that samfile stays alive as long as the
5620  *         # iterator is alive.
5621  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
5622  * 
5623  *         if tid < 0:
5624  */
5625   __pyx_v_self->tabixfile = __pyx_v_tabixfile->tabixfile;
5626
5627   /* "ctabix.pyx":530
5628  *         self.tabixfile = tabixfile.tabixfile
5629  * 
5630  *         if tid < 0:             # <<<<<<<<<<<<<<
5631  *             # seek to start of file to ensure iteration is over
5632  *             # all entries.
5633  */
5634   __pyx_t_3 = (__pyx_v_tid < 0);
5635   if (__pyx_t_3) {
5636
5637     /* "ctabix.pyx":533
5638  *             # seek to start of file to ensure iteration is over
5639  *             # all entries.
5640  *             bgzf_seek( self.tabixfile.fp, 0, 0)             # <<<<<<<<<<<<<<
5641  *             self.iterator = ti_iter_first()
5642  *         else:
5643  */
5644     bgzf_seek(__pyx_v_self->tabixfile->fp, 0, 0);
5645
5646     /* "ctabix.pyx":534
5647  *             # all entries.
5648  *             bgzf_seek( self.tabixfile.fp, 0, 0)
5649  *             self.iterator = ti_iter_first()             # <<<<<<<<<<<<<<
5650  *         else:
5651  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
5652  */
5653     __pyx_v_self->iterator = ti_iter_first();
5654     goto __pyx_L3;
5655   }
5656   /*else*/ {
5657
5658     /* "ctabix.pyx":536
5659  *             self.iterator = ti_iter_first()
5660  *         else:
5661  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)             # <<<<<<<<<<<<<<
5662  * 
5663  *         if <void*>self.iterator == NULL:
5664  */
5665     __pyx_v_self->iterator = ti_queryi(__pyx_v_self->tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end);
5666   }
5667   __pyx_L3:;
5668
5669   /* "ctabix.pyx":538
5670  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
5671  * 
5672  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
5673  *             raise ValueError("malformatted query or wrong sequence name.\n")
5674  * 
5675  */
5676   __pyx_t_3 = (((void *)__pyx_v_self->iterator) == NULL);
5677   if (__pyx_t_3) {
5678
5679     /* "ctabix.pyx":539
5680  * 
5681  *         if <void*>self.iterator == NULL:
5682  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
5683  * 
5684  *     def __iter__(self):
5685  */
5686     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5687     __Pyx_GOTREF(__pyx_t_2);
5688     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
5689     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5690     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5691     goto __pyx_L4;
5692   }
5693   __pyx_L4:;
5694
5695   __pyx_r = 0;
5696   goto __pyx_L0;
5697   __pyx_L1_error:;
5698   __Pyx_XDECREF(__pyx_t_1);
5699   __Pyx_XDECREF(__pyx_t_2);
5700   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5701   __pyx_r = -1;
5702   __pyx_L0:;
5703   __Pyx_RefNannyFinishContext();
5704   return __pyx_r;
5705 }
5706
5707 /* Python wrapper */
5708 static PyObject *__pyx_pw_6ctabix_19TabixIteratorParsed_3__iter__(PyObject *__pyx_v_self); /*proto*/
5709 static PyObject *__pyx_pw_6ctabix_19TabixIteratorParsed_3__iter__(PyObject *__pyx_v_self) {
5710   PyObject *__pyx_r = 0;
5711   __Pyx_RefNannyDeclarations
5712   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
5713   __pyx_r = __pyx_pf_6ctabix_19TabixIteratorParsed_2__iter__(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self));
5714   __Pyx_RefNannyFinishContext();
5715   return __pyx_r;
5716 }
5717
5718 /* "ctabix.pyx":541
5719  *             raise ValueError("malformatted query or wrong sequence name.\n")
5720  * 
5721  *     def __iter__(self):             # <<<<<<<<<<<<<<
5722  *         return self
5723  * 
5724  */
5725
5726 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed_2__iter__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self) {
5727   PyObject *__pyx_r = NULL;
5728   __Pyx_RefNannyDeclarations
5729   __Pyx_RefNannySetupContext("__iter__", 0);
5730
5731   /* "ctabix.pyx":542
5732  * 
5733  *     def __iter__(self):
5734  *         return self             # <<<<<<<<<<<<<<
5735  * 
5736  *     def __next__(self):
5737  */
5738   __Pyx_XDECREF(__pyx_r);
5739   __Pyx_INCREF(((PyObject *)__pyx_v_self));
5740   __pyx_r = ((PyObject *)__pyx_v_self);
5741   goto __pyx_L0;
5742
5743   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5744   __pyx_L0:;
5745   __Pyx_XGIVEREF(__pyx_r);
5746   __Pyx_RefNannyFinishContext();
5747   return __pyx_r;
5748 }
5749
5750 /* Python wrapper */
5751 static PyObject *__pyx_pw_6ctabix_19TabixIteratorParsed_5__next__(PyObject *__pyx_v_self); /*proto*/
5752 static char __pyx_doc_6ctabix_19TabixIteratorParsed_4__next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
5753 #if CYTHON_COMPILING_IN_CPYTHON
5754 struct wrapperbase __pyx_wrapperbase_6ctabix_19TabixIteratorParsed_4__next__;
5755 #endif
5756 static PyObject *__pyx_pw_6ctabix_19TabixIteratorParsed_5__next__(PyObject *__pyx_v_self) {
5757   PyObject *__pyx_r = 0;
5758   __Pyx_RefNannyDeclarations
5759   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
5760   __pyx_r = __pyx_pf_6ctabix_19TabixIteratorParsed_4__next__(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self));
5761   __Pyx_RefNannyFinishContext();
5762   return __pyx_r;
5763 }
5764
5765 /* "ctabix.pyx":544
5766  *         return self
5767  * 
5768  *     def __next__(self):             # <<<<<<<<<<<<<<
5769  *         """python version of next().
5770  * 
5771  */
5772
5773 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed_4__next__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self) {
5774   char *__pyx_v_s;
5775   int __pyx_v_len;
5776   PyObject *__pyx_r = NULL;
5777   __Pyx_RefNannyDeclarations
5778   int __pyx_t_1;
5779   PyObject *__pyx_t_2 = NULL;
5780   PyObject *__pyx_t_3 = NULL;
5781   PyObject *__pyx_t_4 = NULL;
5782   int __pyx_lineno = 0;
5783   const char *__pyx_filename = NULL;
5784   int __pyx_clineno = 0;
5785   __Pyx_RefNannySetupContext("__next__", 0);
5786
5787   /* "ctabix.pyx":552
5788  *         cdef char * s
5789  *         cdef int len
5790  *         while 1:             # <<<<<<<<<<<<<<
5791  *             s = ti_read(self.tabixfile, self.iterator, &len)
5792  *             if s == NULL: raise StopIteration
5793  */
5794   while (1) {
5795     if (!1) break;
5796
5797     /* "ctabix.pyx":553
5798  *         cdef int len
5799  *         while 1:
5800  *             s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
5801  *             if s == NULL: raise StopIteration
5802  *             # todo: read metachar from configuration
5803  */
5804     __pyx_v_s = ti_read(__pyx_v_self->tabixfile, __pyx_v_self->iterator, (&__pyx_v_len));
5805
5806     /* "ctabix.pyx":554
5807  *         while 1:
5808  *             s = ti_read(self.tabixfile, self.iterator, &len)
5809  *             if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
5810  *             # todo: read metachar from configuration
5811  *             if s[0] != '#': break
5812  */
5813     __pyx_t_1 = (__pyx_v_s == NULL);
5814     if (__pyx_t_1) {
5815       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
5816       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5817       goto __pyx_L5;
5818     }
5819     __pyx_L5:;
5820
5821     /* "ctabix.pyx":556
5822  *             if s == NULL: raise StopIteration
5823  *             # todo: read metachar from configuration
5824  *             if s[0] != '#': break             # <<<<<<<<<<<<<<
5825  * 
5826  *         return self.parser(s, len)
5827  */
5828     __pyx_t_1 = ((__pyx_v_s[0]) != '#');
5829     if (__pyx_t_1) {
5830       goto __pyx_L4_break;
5831       goto __pyx_L6;
5832     }
5833     __pyx_L6:;
5834   }
5835   __pyx_L4_break:;
5836
5837   /* "ctabix.pyx":558
5838  *             if s[0] != '#': break
5839  * 
5840  *         return self.parser(s, len)             # <<<<<<<<<<<<<<
5841  * 
5842  *     def __dealloc__(self):
5843  */
5844   __Pyx_XDECREF(__pyx_r);
5845   __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5846   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
5847   __pyx_t_3 = PyInt_FromLong(__pyx_v_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5848   __Pyx_GOTREF(__pyx_t_3);
5849   __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5850   __Pyx_GOTREF(__pyx_t_4);
5851   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
5852   __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
5853   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
5854   __Pyx_GIVEREF(__pyx_t_3);
5855   __pyx_t_2 = 0;
5856   __pyx_t_3 = 0;
5857   __pyx_t_3 = PyObject_Call(((PyObject *)__pyx_v_self->parser), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5858   __Pyx_GOTREF(__pyx_t_3);
5859   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
5860   __pyx_r = __pyx_t_3;
5861   __pyx_t_3 = 0;
5862   goto __pyx_L0;
5863
5864   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5865   goto __pyx_L0;
5866   __pyx_L1_error:;
5867   __Pyx_XDECREF(__pyx_t_2);
5868   __Pyx_XDECREF(__pyx_t_3);
5869   __Pyx_XDECREF(__pyx_t_4);
5870   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5871   __pyx_r = NULL;
5872   __pyx_L0:;
5873   __Pyx_XGIVEREF(__pyx_r);
5874   __Pyx_RefNannyFinishContext();
5875   return __pyx_r;
5876 }
5877
5878 /* Python wrapper */
5879 static void __pyx_pw_6ctabix_19TabixIteratorParsed_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
5880 static void __pyx_pw_6ctabix_19TabixIteratorParsed_7__dealloc__(PyObject *__pyx_v_self) {
5881   __Pyx_RefNannyDeclarations
5882   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
5883   __pyx_pf_6ctabix_19TabixIteratorParsed_6__dealloc__(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self));
5884   __Pyx_RefNannyFinishContext();
5885 }
5886
5887 /* "ctabix.pyx":560
5888  *         return self.parser(s, len)
5889  * 
5890  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
5891  *         if <void*>self.iterator != NULL:
5892  *             ti_iter_destroy(self.iterator)
5893  */
5894
5895 static void __pyx_pf_6ctabix_19TabixIteratorParsed_6__dealloc__(struct __pyx_obj_6ctabix_TabixIteratorParsed *__pyx_v_self) {
5896   __Pyx_RefNannyDeclarations
5897   int __pyx_t_1;
5898   __Pyx_RefNannySetupContext("__dealloc__", 0);
5899
5900   /* "ctabix.pyx":561
5901  * 
5902  *     def __dealloc__(self):
5903  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
5904  *             ti_iter_destroy(self.iterator)
5905  * 
5906  */
5907   __pyx_t_1 = (((void *)__pyx_v_self->iterator) != NULL);
5908   if (__pyx_t_1) {
5909
5910     /* "ctabix.pyx":562
5911  *     def __dealloc__(self):
5912  *         if <void*>self.iterator != NULL:
5913  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
5914  * 
5915  * def tabix_compress( filename_in,
5916  */
5917     ti_iter_destroy(__pyx_v_self->iterator);
5918     goto __pyx_L3;
5919   }
5920   __pyx_L3:;
5921
5922   __Pyx_RefNannyFinishContext();
5923 }
5924
5925 /* Python wrapper */
5926 static PyObject *__pyx_pw_6ctabix_1tabix_compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5927 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    ";
5928 static PyMethodDef __pyx_mdef_6ctabix_1tabix_compress = {__Pyx_NAMESTR("tabix_compress"), (PyCFunction)__pyx_pw_6ctabix_1tabix_compress, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_tabix_compress)};
5929 static PyObject *__pyx_pw_6ctabix_1tabix_compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5930   PyObject *__pyx_v_filename_in = 0;
5931   PyObject *__pyx_v_filename_out = 0;
5932   PyObject *__pyx_v_force = 0;
5933   PyObject *__pyx_r = 0;
5934   __Pyx_RefNannyDeclarations
5935   __Pyx_RefNannySetupContext("tabix_compress (wrapper)", 0);
5936   {
5937     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename_in,&__pyx_n_s__filename_out,&__pyx_n_s__force,0};
5938     PyObject* values[3] = {0,0,0};
5939     values[2] = __pyx_k_30;
5940     if (unlikely(__pyx_kwds)) {
5941       Py_ssize_t kw_args;
5942       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5943       switch (pos_args) {
5944         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5945         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5946         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5947         case  0: break;
5948         default: goto __pyx_L5_argtuple_error;
5949       }
5950       kw_args = PyDict_Size(__pyx_kwds);
5951       switch (pos_args) {
5952         case  0:
5953         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename_in)) != 0)) kw_args--;
5954         else goto __pyx_L5_argtuple_error;
5955         case  1:
5956         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename_out)) != 0)) kw_args--;
5957         else {
5958           __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5959         }
5960         case  2:
5961         if (kw_args > 0) {
5962           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__force);
5963           if (value) { values[2] = value; kw_args--; }
5964         }
5965       }
5966       if (unlikely(kw_args > 0)) {
5967         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tabix_compress") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5968       }
5969     } else {
5970       switch (PyTuple_GET_SIZE(__pyx_args)) {
5971         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5972         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5973         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5974         break;
5975         default: goto __pyx_L5_argtuple_error;
5976       }
5977     }
5978     __pyx_v_filename_in = values[0];
5979     __pyx_v_filename_out = values[1];
5980     __pyx_v_force = values[2];
5981   }
5982   goto __pyx_L4_argument_unpacking_done;
5983   __pyx_L5_argtuple_error:;
5984   __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5985   __pyx_L3_error:;
5986   __Pyx_AddTraceback("ctabix.tabix_compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
5987   __Pyx_RefNannyFinishContext();
5988   return NULL;
5989   __pyx_L4_argument_unpacking_done:;
5990   __pyx_r = __pyx_pf_6ctabix_tabix_compress(__pyx_self, __pyx_v_filename_in, __pyx_v_filename_out, __pyx_v_force);
5991   __Pyx_RefNannyFinishContext();
5992   return __pyx_r;
5993 }
5994
5995 /* "ctabix.pyx":564
5996  *             ti_iter_destroy(self.iterator)
5997  * 
5998  * def tabix_compress( filename_in,             # <<<<<<<<<<<<<<
5999  *                     filename_out,
6000  *                     force = False ):
6001  */
6002
6003 static PyObject *__pyx_pf_6ctabix_tabix_compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_in, PyObject *__pyx_v_filename_out, PyObject *__pyx_v_force) {
6004   int __pyx_v_WINDOW_SIZE;
6005   int __pyx_v_c;
6006   int __pyx_v_r;
6007   void *__pyx_v_buffer;
6008   BGZF *__pyx_v_fp;
6009   int __pyx_v_fd_src;
6010   int __pyx_v_O_RDONLY;
6011   PyObject *__pyx_v_fn = NULL;
6012   PyObject *__pyx_r = NULL;
6013   __Pyx_RefNannyDeclarations
6014   int __pyx_t_1;
6015   int __pyx_t_2;
6016   PyObject *__pyx_t_3 = NULL;
6017   PyObject *__pyx_t_4 = NULL;
6018   PyObject *__pyx_t_5 = NULL;
6019   int __pyx_t_6;
6020   int __pyx_t_7;
6021   char *__pyx_t_8;
6022   int __pyx_lineno = 0;
6023   const char *__pyx_filename = NULL;
6024   int __pyx_clineno = 0;
6025   __Pyx_RefNannySetupContext("tabix_compress", 0);
6026
6027   /* "ctabix.pyx":573
6028  *     '''
6029  * 
6030  *     if not force and os.path.exists(filename_out ):             # <<<<<<<<<<<<<<
6031  *         raise IOError( "Filename '%s' already exists, use *force* to overwrite" % filename_out)
6032  * 
6033  */
6034   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6035   __pyx_t_2 = (!__pyx_t_1);
6036   if (__pyx_t_2) {
6037     __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6038     __Pyx_GOTREF(__pyx_t_3);
6039     __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6040     __Pyx_GOTREF(__pyx_t_4);
6041     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6042     __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6043     __Pyx_GOTREF(__pyx_t_3);
6044     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6045     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6046     __Pyx_GOTREF(__pyx_t_4);
6047     __Pyx_INCREF(__pyx_v_filename_out);
6048     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename_out);
6049     __Pyx_GIVEREF(__pyx_v_filename_out);
6050     __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 = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6051     __Pyx_GOTREF(__pyx_t_5);
6052     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6053     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
6054     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6055     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6056     __pyx_t_6 = __pyx_t_1;
6057   } else {
6058     __pyx_t_6 = __pyx_t_2;
6059   }
6060   if (__pyx_t_6) {
6061
6062     /* "ctabix.pyx":574
6063  * 
6064  *     if not force and os.path.exists(filename_out ):
6065  *         raise IOError( "Filename '%s' already exists, use *force* to overwrite" % filename_out)             # <<<<<<<<<<<<<<
6066  * 
6067  *     cdef int WINDOW_SIZE
6068  */
6069     __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), __pyx_v_filename_out); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6070     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
6071     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6072     __Pyx_GOTREF(__pyx_t_4);
6073     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
6074     __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
6075     __pyx_t_5 = 0;
6076     __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 = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6077     __Pyx_GOTREF(__pyx_t_5);
6078     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
6079     __Pyx_Raise(__pyx_t_5, 0, 0, 0);
6080     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6081     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6082     goto __pyx_L3;
6083   }
6084   __pyx_L3:;
6085
6086   /* "ctabix.pyx":583
6087  * 
6088  *     cdef int O_RDONLY
6089  *     O_RDONLY = os.O_RDONLY             # <<<<<<<<<<<<<<
6090  * 
6091  *     WINDOW_SIZE = 64 * 1024
6092  */
6093   __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6094   __Pyx_GOTREF(__pyx_t_5);
6095   __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 = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6096   __Pyx_GOTREF(__pyx_t_4);
6097   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6098   __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 = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6099   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6100   __pyx_v_O_RDONLY = __pyx_t_7;
6101
6102   /* "ctabix.pyx":585
6103  *     O_RDONLY = os.O_RDONLY
6104  * 
6105  *     WINDOW_SIZE = 64 * 1024             # <<<<<<<<<<<<<<
6106  * 
6107  *     fn = _force_bytes(filename_out)
6108  */
6109   __pyx_v_WINDOW_SIZE = 65536;
6110
6111   /* "ctabix.pyx":587
6112  *     WINDOW_SIZE = 64 * 1024
6113  * 
6114  *     fn = _force_bytes(filename_out)             # <<<<<<<<<<<<<<
6115  *     fp = bgzf_open( fn, "w")
6116  *     if fp == NULL:
6117  */
6118   __pyx_t_4 = ((PyObject *)__pyx_f_6ctabix__force_bytes(__pyx_v_filename_out)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6119   __Pyx_GOTREF(__pyx_t_4);
6120   __pyx_v_fn = ((PyObject*)__pyx_t_4);
6121   __pyx_t_4 = 0;
6122
6123   /* "ctabix.pyx":588
6124  * 
6125  *     fn = _force_bytes(filename_out)
6126  *     fp = bgzf_open( fn, "w")             # <<<<<<<<<<<<<<
6127  *     if fp == NULL:
6128  *         raise IOError( "could not open '%s' for writing" )
6129  */
6130   __pyx_t_8 = PyBytes_AsString(((PyObject *)__pyx_v_fn)); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6131   __pyx_v_fp = bgzf_open(__pyx_t_8, __pyx_k__w);
6132
6133   /* "ctabix.pyx":589
6134  *     fn = _force_bytes(filename_out)
6135  *     fp = bgzf_open( fn, "w")
6136  *     if fp == NULL:             # <<<<<<<<<<<<<<
6137  *         raise IOError( "could not open '%s' for writing" )
6138  * 
6139  */
6140   __pyx_t_6 = (__pyx_v_fp == NULL);
6141   if (__pyx_t_6) {
6142
6143     /* "ctabix.pyx":590
6144  *     fp = bgzf_open( fn, "w")
6145  *     if fp == NULL:
6146  *         raise IOError( "could not open '%s' for writing" )             # <<<<<<<<<<<<<<
6147  * 
6148  *     fn = _force_bytes(filename_in)
6149  */
6150     __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6151     __Pyx_GOTREF(__pyx_t_4);
6152     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
6153     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6154     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6155     goto __pyx_L4;
6156   }
6157   __pyx_L4:;
6158
6159   /* "ctabix.pyx":592
6160  *         raise IOError( "could not open '%s' for writing" )
6161  * 
6162  *     fn = _force_bytes(filename_in)             # <<<<<<<<<<<<<<
6163  *     fd_src = open(fn, O_RDONLY)
6164  *     if fd_src == 0:
6165  */
6166   __pyx_t_4 = ((PyObject *)__pyx_f_6ctabix__force_bytes(__pyx_v_filename_in)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6167   __Pyx_GOTREF(__pyx_t_4);
6168   __Pyx_DECREF(((PyObject *)__pyx_v_fn));
6169   __pyx_v_fn = ((PyObject*)__pyx_t_4);
6170   __pyx_t_4 = 0;
6171
6172   /* "ctabix.pyx":593
6173  * 
6174  *     fn = _force_bytes(filename_in)
6175  *     fd_src = open(fn, O_RDONLY)             # <<<<<<<<<<<<<<
6176  *     if fd_src == 0:
6177  *         raise IOError( "could not open '%s' for reading" )
6178  */
6179   __pyx_t_8 = PyBytes_AsString(((PyObject *)__pyx_v_fn)); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6180   __pyx_v_fd_src = open(__pyx_t_8, __pyx_v_O_RDONLY);
6181
6182   /* "ctabix.pyx":594
6183  *     fn = _force_bytes(filename_in)
6184  *     fd_src = open(fn, O_RDONLY)
6185  *     if fd_src == 0:             # <<<<<<<<<<<<<<
6186  *         raise IOError( "could not open '%s' for reading" )
6187  * 
6188  */
6189   __pyx_t_6 = (__pyx_v_fd_src == 0);
6190   if (__pyx_t_6) {
6191
6192     /* "ctabix.pyx":595
6193  *     fd_src = open(fn, O_RDONLY)
6194  *     if fd_src == 0:
6195  *         raise IOError( "could not open '%s' for reading" )             # <<<<<<<<<<<<<<
6196  * 
6197  *     buffer = malloc(WINDOW_SIZE)
6198  */
6199     __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_35), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6200     __Pyx_GOTREF(__pyx_t_4);
6201     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
6202     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6203     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6204     goto __pyx_L5;
6205   }
6206   __pyx_L5:;
6207
6208   /* "ctabix.pyx":597
6209  *         raise IOError( "could not open '%s' for reading" )
6210  * 
6211  *     buffer = malloc(WINDOW_SIZE)             # <<<<<<<<<<<<<<
6212  *     c = 1
6213  * 
6214  */
6215   __pyx_v_buffer = malloc(__pyx_v_WINDOW_SIZE);
6216
6217   /* "ctabix.pyx":598
6218  * 
6219  *     buffer = malloc(WINDOW_SIZE)
6220  *     c = 1             # <<<<<<<<<<<<<<
6221  * 
6222  *     while c > 0:
6223  */
6224   __pyx_v_c = 1;
6225
6226   /* "ctabix.pyx":600
6227  *     c = 1
6228  * 
6229  *     while c > 0:             # <<<<<<<<<<<<<<
6230  *         c = read(fd_src, buffer, WINDOW_SIZE)
6231  *         r = bgzf_write(fp, buffer, c)
6232  */
6233   while (1) {
6234     __pyx_t_6 = (__pyx_v_c > 0);
6235     if (!__pyx_t_6) break;
6236
6237     /* "ctabix.pyx":601
6238  * 
6239  *     while c > 0:
6240  *         c = read(fd_src, buffer, WINDOW_SIZE)             # <<<<<<<<<<<<<<
6241  *         r = bgzf_write(fp, buffer, c)
6242  *         if r < 0:
6243  */
6244     __pyx_v_c = read(__pyx_v_fd_src, __pyx_v_buffer, __pyx_v_WINDOW_SIZE);
6245
6246     /* "ctabix.pyx":602
6247  *     while c > 0:
6248  *         c = read(fd_src, buffer, WINDOW_SIZE)
6249  *         r = bgzf_write(fp, buffer, c)             # <<<<<<<<<<<<<<
6250  *         if r < 0:
6251  *             free( buffer )
6252  */
6253     __pyx_v_r = bgzf_write(__pyx_v_fp, __pyx_v_buffer, __pyx_v_c);
6254
6255     /* "ctabix.pyx":603
6256  *         c = read(fd_src, buffer, WINDOW_SIZE)
6257  *         r = bgzf_write(fp, buffer, c)
6258  *         if r < 0:             # <<<<<<<<<<<<<<
6259  *             free( buffer )
6260  *             raise OSError("writing failed")
6261  */
6262     __pyx_t_6 = (__pyx_v_r < 0);
6263     if (__pyx_t_6) {
6264
6265       /* "ctabix.pyx":604
6266  *         r = bgzf_write(fp, buffer, c)
6267  *         if r < 0:
6268  *             free( buffer )             # <<<<<<<<<<<<<<
6269  *             raise OSError("writing failed")
6270  * 
6271  */
6272       free(__pyx_v_buffer);
6273
6274       /* "ctabix.pyx":605
6275  *         if r < 0:
6276  *             free( buffer )
6277  *             raise OSError("writing failed")             # <<<<<<<<<<<<<<
6278  * 
6279  *     free( buffer )
6280  */
6281       __pyx_t_4 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6282       __Pyx_GOTREF(__pyx_t_4);
6283       __Pyx_Raise(__pyx_t_4, 0, 0, 0);
6284       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6285       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6286       goto __pyx_L8;
6287     }
6288     __pyx_L8:;
6289   }
6290
6291   /* "ctabix.pyx":607
6292  *             raise OSError("writing failed")
6293  * 
6294  *     free( buffer )             # <<<<<<<<<<<<<<
6295  *     r = bgzf_close(fp)
6296  *     if r < 0: raise OSError("writing failed")
6297  */
6298   free(__pyx_v_buffer);
6299
6300   /* "ctabix.pyx":608
6301  * 
6302  *     free( buffer )
6303  *     r = bgzf_close(fp)             # <<<<<<<<<<<<<<
6304  *     if r < 0: raise OSError("writing failed")
6305  * 
6306  */
6307   __pyx_v_r = bgzf_close(__pyx_v_fp);
6308
6309   /* "ctabix.pyx":609
6310  *     free( buffer )
6311  *     r = bgzf_close(fp)
6312  *     if r < 0: raise OSError("writing failed")             # <<<<<<<<<<<<<<
6313  * 
6314  * def tabix_index( filename,
6315  */
6316   __pyx_t_6 = (__pyx_v_r < 0);
6317   if (__pyx_t_6) {
6318     __pyx_t_4 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_38), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6319     __Pyx_GOTREF(__pyx_t_4);
6320     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
6321     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6322     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6323     goto __pyx_L9;
6324   }
6325   __pyx_L9:;
6326
6327   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6328   goto __pyx_L0;
6329   __pyx_L1_error:;
6330   __Pyx_XDECREF(__pyx_t_3);
6331   __Pyx_XDECREF(__pyx_t_4);
6332   __Pyx_XDECREF(__pyx_t_5);
6333   __Pyx_AddTraceback("ctabix.tabix_compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
6334   __pyx_r = NULL;
6335   __pyx_L0:;
6336   __Pyx_XDECREF(__pyx_v_fn);
6337   __Pyx_XGIVEREF(__pyx_r);
6338   __Pyx_RefNannyFinishContext();
6339   return __pyx_r;
6340 }
6341
6342 /* Python wrapper */
6343 static PyObject *__pyx_pw_6ctabix_3tabix_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6344 static char __pyx_doc_6ctabix_2tabix_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    ";
6345 static PyMethodDef __pyx_mdef_6ctabix_3tabix_index = {__Pyx_NAMESTR("tabix_index"), (PyCFunction)__pyx_pw_6ctabix_3tabix_index, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_2tabix_index)};
6346 static PyObject *__pyx_pw_6ctabix_3tabix_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6347   PyObject *__pyx_v_filename = 0;
6348   PyObject *__pyx_v_force = 0;
6349   PyObject *__pyx_v_seq_col = 0;
6350   PyObject *__pyx_v_start_col = 0;
6351   PyObject *__pyx_v_end_col = 0;
6352   PyObject *__pyx_v_preset = 0;
6353   PyObject *__pyx_v_meta_char = 0;
6354   PyObject *__pyx_v_zerobased = 0;
6355   PyObject *__pyx_r = 0;
6356   __Pyx_RefNannyDeclarations
6357   __Pyx_RefNannySetupContext("tabix_index (wrapper)", 0);
6358   {
6359     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};
6360     PyObject* values[8] = {0,0,0,0,0,0,0,0};
6361     values[1] = __pyx_k_39;
6362
6363     /* "ctabix.pyx":613
6364  * def tabix_index( filename,
6365  *                  force = False,
6366  *                  seq_col = None,             # <<<<<<<<<<<<<<
6367  *                  start_col = None,
6368  *                  end_col = None,
6369  */
6370     values[2] = ((PyObject *)Py_None);
6371
6372     /* "ctabix.pyx":614
6373  *                  force = False,
6374  *                  seq_col = None,
6375  *                  start_col = None,             # <<<<<<<<<<<<<<
6376  *                  end_col = None,
6377  *                  preset = None,
6378  */
6379     values[3] = ((PyObject *)Py_None);
6380
6381     /* "ctabix.pyx":615
6382  *                  seq_col = None,
6383  *                  start_col = None,
6384  *                  end_col = None,             # <<<<<<<<<<<<<<
6385  *                  preset = None,
6386  *                  meta_char = "#",
6387  */
6388     values[4] = ((PyObject *)Py_None);
6389
6390     /* "ctabix.pyx":616
6391  *                  start_col = None,
6392  *                  end_col = None,
6393  *                  preset = None,             # <<<<<<<<<<<<<<
6394  *                  meta_char = "#",
6395  *                  zerobased = False,
6396  */
6397     values[5] = ((PyObject *)Py_None);
6398     values[6] = ((PyObject *)__pyx_kp_s_40);
6399     values[7] = __pyx_k_41;
6400     if (unlikely(__pyx_kwds)) {
6401       Py_ssize_t kw_args;
6402       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6403       switch (pos_args) {
6404         case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
6405         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
6406         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
6407         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6408         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6409         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6410         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6411         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6412         case  0: break;
6413         default: goto __pyx_L5_argtuple_error;
6414       }
6415       kw_args = PyDict_Size(__pyx_kwds);
6416       switch (pos_args) {
6417         case  0:
6418         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename)) != 0)) kw_args--;
6419         else goto __pyx_L5_argtuple_error;
6420         case  1:
6421         if (kw_args > 0) {
6422           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__force);
6423           if (value) { values[1] = value; kw_args--; }
6424         }
6425         case  2:
6426         if (kw_args > 0) {
6427           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq_col);
6428           if (value) { values[2] = value; kw_args--; }
6429         }
6430         case  3:
6431         if (kw_args > 0) {
6432           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start_col);
6433           if (value) { values[3] = value; kw_args--; }
6434         }
6435         case  4:
6436         if (kw_args > 0) {
6437           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end_col);
6438           if (value) { values[4] = value; kw_args--; }
6439         }
6440         case  5:
6441         if (kw_args > 0) {
6442           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__preset);
6443           if (value) { values[5] = value; kw_args--; }
6444         }
6445         case  6:
6446         if (kw_args > 0) {
6447           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__meta_char);
6448           if (value) { values[6] = value; kw_args--; }
6449         }
6450         case  7:
6451         if (kw_args > 0) {
6452           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__zerobased);
6453           if (value) { values[7] = value; kw_args--; }
6454         }
6455       }
6456       if (unlikely(kw_args > 0)) {
6457         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tabix_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6458       }
6459     } else {
6460       switch (PyTuple_GET_SIZE(__pyx_args)) {
6461         case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
6462         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
6463         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
6464         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6465         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6466         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6467         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6468         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6469         break;
6470         default: goto __pyx_L5_argtuple_error;
6471       }
6472     }
6473     __pyx_v_filename = values[0];
6474     __pyx_v_force = values[1];
6475     __pyx_v_seq_col = values[2];
6476     __pyx_v_start_col = values[3];
6477     __pyx_v_end_col = values[4];
6478     __pyx_v_preset = values[5];
6479     __pyx_v_meta_char = values[6];
6480     __pyx_v_zerobased = values[7];
6481   }
6482   goto __pyx_L4_argument_unpacking_done;
6483   __pyx_L5_argtuple_error:;
6484   __Pyx_RaiseArgtupleInvalid("tabix_index", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6485   __pyx_L3_error:;
6486   __Pyx_AddTraceback("ctabix.tabix_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
6487   __Pyx_RefNannyFinishContext();
6488   return NULL;
6489   __pyx_L4_argument_unpacking_done:;
6490   __pyx_r = __pyx_pf_6ctabix_2tabix_index(__pyx_self, __pyx_v_filename, __pyx_v_force, __pyx_v_seq_col, __pyx_v_start_col, __pyx_v_end_col, __pyx_v_preset, __pyx_v_meta_char, __pyx_v_zerobased);
6491   __Pyx_RefNannyFinishContext();
6492   return __pyx_r;
6493 }
6494
6495 /* "ctabix.pyx":611
6496  *     if r < 0: raise OSError("writing failed")
6497  * 
6498  * def tabix_index( filename,             # <<<<<<<<<<<<<<
6499  *                  force = False,
6500  *                  seq_col = None,
6501  */
6502
6503 static PyObject *__pyx_pf_6ctabix_2tabix_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_force, PyObject *__pyx_v_seq_col, PyObject *__pyx_v_start_col, PyObject *__pyx_v_end_col, PyObject *__pyx_v_preset, PyObject *__pyx_v_meta_char, PyObject *__pyx_v_zerobased) {
6504   PyObject *__pyx_v_preset2conf = NULL;
6505   PyObject *__pyx_v_conf_data = NULL;
6506   ti_conf_t __pyx_v_conf;
6507   PyObject *__pyx_v_fn = NULL;
6508   PyObject *__pyx_r = NULL;
6509   __Pyx_RefNannyDeclarations
6510   PyObject *__pyx_t_1 = NULL;
6511   PyObject *__pyx_t_2 = NULL;
6512   PyObject *__pyx_t_3 = NULL;
6513   int __pyx_t_4;
6514   int __pyx_t_5;
6515   PyObject *__pyx_t_6 = NULL;
6516   int __pyx_t_7;
6517   PyObject *__pyx_t_8 = NULL;
6518   PyObject *__pyx_t_9 = NULL;
6519   PyObject *__pyx_t_10 = NULL;
6520   int __pyx_t_11;
6521   PyObject *__pyx_t_12 = NULL;
6522   PyObject *__pyx_t_13 = NULL;
6523   PyObject *__pyx_t_14 = NULL;
6524   PyObject *(*__pyx_t_15)(PyObject *);
6525   int32_t __pyx_t_16;
6526   int32_t __pyx_t_17;
6527   int32_t __pyx_t_18;
6528   int32_t __pyx_t_19;
6529   int32_t __pyx_t_20;
6530   int32_t __pyx_t_21;
6531   char *__pyx_t_22;
6532   int __pyx_lineno = 0;
6533   const char *__pyx_filename = NULL;
6534   int __pyx_clineno = 0;
6535   __Pyx_RefNannySetupContext("tabix_index", 0);
6536   __Pyx_INCREF(__pyx_v_filename);
6537   __Pyx_INCREF(__pyx_v_end_col);
6538   __Pyx_INCREF(__pyx_v_preset);
6539
6540   /* "ctabix.pyx":653
6541  *     '''
6542  * 
6543  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)             # <<<<<<<<<<<<<<
6544  * 
6545  *     if not filename.endswith(".gz"):
6546  */
6547   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6548   __Pyx_GOTREF(__pyx_t_1);
6549   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6550   __Pyx_GOTREF(__pyx_t_2);
6551   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6552   __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6553   __Pyx_GOTREF(__pyx_t_1);
6554   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6555   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6556   __Pyx_GOTREF(__pyx_t_2);
6557   __Pyx_INCREF(__pyx_v_filename);
6558   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
6559   __Pyx_GIVEREF(__pyx_v_filename);
6560   __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 = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6561   __Pyx_GOTREF(__pyx_t_3);
6562   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6563   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
6564   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6565   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6566   __pyx_t_5 = (!__pyx_t_4);
6567   if (__pyx_t_5) {
6568     __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_42), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6569     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6570     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6571     __Pyx_GOTREF(__pyx_t_2);
6572     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
6573     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
6574     __pyx_t_3 = 0;
6575     __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 = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6576     __Pyx_GOTREF(__pyx_t_3);
6577     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
6578     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6579     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6580     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6581     goto __pyx_L3;
6582   }
6583   __pyx_L3:;
6584
6585   /* "ctabix.pyx":655
6586  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)
6587  * 
6588  *     if not filename.endswith(".gz"):             # <<<<<<<<<<<<<<
6589  *         tabix_compress( filename, filename + ".gz", force = force )
6590  *         os.unlink( filename )
6591  */
6592   __pyx_t_3 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__endswith); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6593   __Pyx_GOTREF(__pyx_t_3);
6594   __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6595   __Pyx_GOTREF(__pyx_t_2);
6596   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6597   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6598   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6599   __pyx_t_4 = (!__pyx_t_5);
6600   if (__pyx_t_4) {
6601
6602     /* "ctabix.pyx":656
6603  * 
6604  *     if not filename.endswith(".gz"):
6605  *         tabix_compress( filename, filename + ".gz", force = force )             # <<<<<<<<<<<<<<
6606  *         os.unlink( filename )
6607  *         filename += ".gz"
6608  */
6609     __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6610     __Pyx_GOTREF(__pyx_t_2);
6611     __pyx_t_3 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_43)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6612     __Pyx_GOTREF(__pyx_t_3);
6613     __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6614     __Pyx_GOTREF(__pyx_t_1);
6615     __Pyx_INCREF(__pyx_v_filename);
6616     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
6617     __Pyx_GIVEREF(__pyx_v_filename);
6618     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
6619     __Pyx_GIVEREF(__pyx_t_3);
6620     __pyx_t_3 = 0;
6621     __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6622     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6623     if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__force), __pyx_v_force) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6624     __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6625     __Pyx_GOTREF(__pyx_t_6);
6626     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6627     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
6628     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6629     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6630
6631     /* "ctabix.pyx":657
6632  *     if not filename.endswith(".gz"):
6633  *         tabix_compress( filename, filename + ".gz", force = force )
6634  *         os.unlink( filename )             # <<<<<<<<<<<<<<
6635  *         filename += ".gz"
6636  * 
6637  */
6638     __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6639     __Pyx_GOTREF(__pyx_t_6);
6640     __pyx_t_3 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__unlink); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6641     __Pyx_GOTREF(__pyx_t_3);
6642     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6643     __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6644     __Pyx_GOTREF(__pyx_t_6);
6645     __Pyx_INCREF(__pyx_v_filename);
6646     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_filename);
6647     __Pyx_GIVEREF(__pyx_v_filename);
6648     __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 = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6649     __Pyx_GOTREF(__pyx_t_1);
6650     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6651     __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
6652     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6653
6654     /* "ctabix.pyx":658
6655  *         tabix_compress( filename, filename + ".gz", force = force )
6656  *         os.unlink( filename )
6657  *         filename += ".gz"             # <<<<<<<<<<<<<<
6658  * 
6659  *     if not force and os.path.exists(filename + ".tbi" ):
6660  */
6661     __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_filename, ((PyObject *)__pyx_kp_s_43)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6662     __Pyx_GOTREF(__pyx_t_1);
6663     __Pyx_DECREF(__pyx_v_filename);
6664     __pyx_v_filename = __pyx_t_1;
6665     __pyx_t_1 = 0;
6666     goto __pyx_L4;
6667   }
6668   __pyx_L4:;
6669
6670   /* "ctabix.pyx":660
6671  *         filename += ".gz"
6672  * 
6673  *     if not force and os.path.exists(filename + ".tbi" ):             # <<<<<<<<<<<<<<
6674  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )
6675  * 
6676  */
6677   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6678   __pyx_t_5 = (!__pyx_t_4);
6679   if (__pyx_t_5) {
6680     __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6681     __Pyx_GOTREF(__pyx_t_1);
6682     __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6683     __Pyx_GOTREF(__pyx_t_6);
6684     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6685     __pyx_t_1 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6686     __Pyx_GOTREF(__pyx_t_1);
6687     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6688     __pyx_t_6 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6689     __Pyx_GOTREF(__pyx_t_6);
6690     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6691     __Pyx_GOTREF(__pyx_t_3);
6692     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
6693     __Pyx_GIVEREF(__pyx_t_6);
6694     __pyx_t_6 = 0;
6695     __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 = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6696     __Pyx_GOTREF(__pyx_t_6);
6697     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6698     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6699     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6700     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6701     __pyx_t_7 = __pyx_t_4;
6702   } else {
6703     __pyx_t_7 = __pyx_t_5;
6704   }
6705   if (__pyx_t_7) {
6706
6707     /* "ctabix.pyx":661
6708  * 
6709  *     if not force and os.path.exists(filename + ".tbi" ):
6710  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )             # <<<<<<<<<<<<<<
6711  * 
6712  *     # columns (1-based)
6713  */
6714     __pyx_t_6 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_46), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6715     __Pyx_GOTREF(__pyx_t_6);
6716     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
6717     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6718     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6719     goto __pyx_L5;
6720   }
6721   __pyx_L5:;
6722
6723   /* "ctabix.pyx":666
6724  *     # preset-code, contig, start, end, metachar for commends, lines to ignore at beginning
6725  *     # 0 is a missing column
6726  *     preset2conf = {             # <<<<<<<<<<<<<<
6727  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
6728  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
6729  */
6730   __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6731   __Pyx_GOTREF(((PyObject *)__pyx_t_6));
6732
6733   /* "ctabix.pyx":667
6734  *     # 0 is a missing column
6735  *     preset2conf = {
6736  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),             # <<<<<<<<<<<<<<
6737  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
6738  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
6739  */
6740   __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6741   __Pyx_GOTREF(__pyx_t_3);
6742   __Pyx_INCREF(__pyx_int_0);
6743   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
6744   __Pyx_GIVEREF(__pyx_int_0);
6745   __Pyx_INCREF(__pyx_int_1);
6746   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
6747   __Pyx_GIVEREF(__pyx_int_1);
6748   __Pyx_INCREF(__pyx_int_4);
6749   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_4);
6750   __Pyx_GIVEREF(__pyx_int_4);
6751   __Pyx_INCREF(__pyx_int_5);
6752   PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_int_5);
6753   __Pyx_GIVEREF(__pyx_int_5);
6754   __Pyx_INCREF(__pyx_int_35);
6755   PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_int_35);
6756   __Pyx_GIVEREF(__pyx_int_35);
6757   __Pyx_INCREF(__pyx_int_0);
6758   PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_int_0);
6759   __Pyx_GIVEREF(__pyx_int_0);
6760   if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__gff), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6761   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6762
6763   /* "ctabix.pyx":668
6764  *     preset2conf = {
6765  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
6766  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),             # <<<<<<<<<<<<<<
6767  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
6768  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
6769  */
6770   __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6771   __Pyx_GOTREF(__pyx_t_3);
6772   __Pyx_INCREF(__pyx_int_65536);
6773   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_65536);
6774   __Pyx_GIVEREF(__pyx_int_65536);
6775   __Pyx_INCREF(__pyx_int_1);
6776   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
6777   __Pyx_GIVEREF(__pyx_int_1);
6778   __Pyx_INCREF(__pyx_int_2);
6779   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
6780   __Pyx_GIVEREF(__pyx_int_2);
6781   __Pyx_INCREF(__pyx_int_3);
6782   PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_int_3);
6783   __Pyx_GIVEREF(__pyx_int_3);
6784   __Pyx_INCREF(__pyx_int_35);
6785   PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_int_35);
6786   __Pyx_GIVEREF(__pyx_int_35);
6787   __Pyx_INCREF(__pyx_int_0);
6788   PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_int_0);
6789   __Pyx_GIVEREF(__pyx_int_0);
6790   if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__bed), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6791   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6792
6793   /* "ctabix.pyx":669
6794  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
6795  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
6796  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),             # <<<<<<<<<<<<<<
6797  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
6798  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
6799  */
6800   __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6801   __Pyx_GOTREF(__pyx_t_3);
6802   __Pyx_INCREF(__pyx_int_65536);
6803   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_65536);
6804   __Pyx_GIVEREF(__pyx_int_65536);
6805   __Pyx_INCREF(__pyx_int_15);
6806   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_15);
6807   __Pyx_GIVEREF(__pyx_int_15);
6808   __Pyx_INCREF(__pyx_int_17);
6809   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_17);
6810   __Pyx_GIVEREF(__pyx_int_17);
6811   __Pyx_INCREF(__pyx_int_18);
6812   PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_int_18);
6813   __Pyx_GIVEREF(__pyx_int_18);
6814   __Pyx_INCREF(__pyx_int_35);
6815   PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_int_35);
6816   __Pyx_GIVEREF(__pyx_int_35);
6817   __Pyx_INCREF(__pyx_int_0);
6818   PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_int_0);
6819   __Pyx_GIVEREF(__pyx_int_0);
6820   if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__psltbl), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6821   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6822
6823   /* "ctabix.pyx":670
6824  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
6825  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
6826  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
6827  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
6828  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),
6829  */
6830   __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6831   __Pyx_GOTREF(__pyx_t_3);
6832   __Pyx_INCREF(__pyx_int_1);
6833   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
6834   __Pyx_GIVEREF(__pyx_int_1);
6835   __Pyx_INCREF(__pyx_int_3);
6836   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
6837   __Pyx_GIVEREF(__pyx_int_3);
6838   __Pyx_INCREF(__pyx_int_4);
6839   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_4);
6840   __Pyx_GIVEREF(__pyx_int_4);
6841   __Pyx_INCREF(__pyx_int_0);
6842   PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_int_0);
6843   __Pyx_GIVEREF(__pyx_int_0);
6844   __Pyx_INCREF(__pyx_int_35);
6845   PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_int_35);
6846   __Pyx_GIVEREF(__pyx_int_35);
6847   __Pyx_INCREF(__pyx_int_0);
6848   PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_int_0);
6849   __Pyx_GIVEREF(__pyx_int_0);
6850   if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__sam), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6851   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6852
6853   /* "ctabix.pyx":671
6854  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
6855  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
6856  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
6857  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),
6858  *         }
6859  */
6860   __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6861   __Pyx_GOTREF(__pyx_t_3);
6862   __Pyx_INCREF(__pyx_int_2);
6863   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_2);
6864   __Pyx_GIVEREF(__pyx_int_2);
6865   __Pyx_INCREF(__pyx_int_1);
6866   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
6867   __Pyx_GIVEREF(__pyx_int_1);
6868   __Pyx_INCREF(__pyx_int_2);
6869   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
6870   __Pyx_GIVEREF(__pyx_int_2);
6871   __Pyx_INCREF(__pyx_int_0);
6872   PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_int_0);
6873   __Pyx_GIVEREF(__pyx_int_0);
6874   __Pyx_INCREF(__pyx_int_35);
6875   PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_int_35);
6876   __Pyx_GIVEREF(__pyx_int_35);
6877   __Pyx_INCREF(__pyx_int_0);
6878   PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_int_0);
6879   __Pyx_GIVEREF(__pyx_int_0);
6880   if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__vcf), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6881   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6882
6883   /* "ctabix.pyx":672
6884  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
6885  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
6886  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
6887  *         }
6888  * 
6889  */
6890   __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6891   __Pyx_GOTREF(__pyx_t_3);
6892   __Pyx_INCREF(__pyx_int_3);
6893   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
6894   __Pyx_GIVEREF(__pyx_int_3);
6895   __Pyx_INCREF(__pyx_int_1);
6896   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
6897   __Pyx_GIVEREF(__pyx_int_1);
6898   __Pyx_INCREF(__pyx_int_2);
6899   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
6900   __Pyx_GIVEREF(__pyx_int_2);
6901   __Pyx_INCREF(__pyx_int_0);
6902   PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_int_0);
6903   __Pyx_GIVEREF(__pyx_int_0);
6904   __Pyx_INCREF(__pyx_int_35);
6905   PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_int_35);
6906   __Pyx_GIVEREF(__pyx_int_35);
6907   __Pyx_INCREF(__pyx_int_0);
6908   PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_int_0);
6909   __Pyx_GIVEREF(__pyx_int_0);
6910   if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__pileup), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6911   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6912   __pyx_v_preset2conf = __pyx_t_6;
6913   __pyx_t_6 = 0;
6914
6915   /* "ctabix.pyx":675
6916  *         }
6917  * 
6918  *     if preset:             # <<<<<<<<<<<<<<
6919  *         try:
6920  *             conf_data = preset2conf[preset]
6921  */
6922   __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_preset); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6923   if (__pyx_t_7) {
6924
6925     /* "ctabix.pyx":676
6926  * 
6927  *     if preset:
6928  *         try:             # <<<<<<<<<<<<<<
6929  *             conf_data = preset2conf[preset]
6930  *         except KeyError:
6931  */
6932     {
6933       __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
6934       __Pyx_XGOTREF(__pyx_t_8);
6935       __Pyx_XGOTREF(__pyx_t_9);
6936       __Pyx_XGOTREF(__pyx_t_10);
6937       /*try:*/ {
6938
6939         /* "ctabix.pyx":677
6940  *     if preset:
6941  *         try:
6942  *             conf_data = preset2conf[preset]             # <<<<<<<<<<<<<<
6943  *         except KeyError:
6944  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
6945  */
6946         __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_preset2conf), __pyx_v_preset); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
6947         __Pyx_GOTREF(__pyx_t_6);
6948         __pyx_v_conf_data = __pyx_t_6;
6949         __pyx_t_6 = 0;
6950       }
6951       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
6952       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6953       __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
6954       goto __pyx_L14_try_end;
6955       __pyx_L7_error:;
6956       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6957       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6958       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6959       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
6960
6961       /* "ctabix.pyx":678
6962  *         try:
6963  *             conf_data = preset2conf[preset]
6964  *         except KeyError:             # <<<<<<<<<<<<<<
6965  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
6966  *     else:
6967  */
6968       __pyx_t_11 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
6969       if (__pyx_t_11) {
6970         __Pyx_AddTraceback("ctabix.tabix_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
6971         if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_3, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
6972         __Pyx_GOTREF(__pyx_t_6);
6973         __Pyx_GOTREF(__pyx_t_3);
6974         __Pyx_GOTREF(__pyx_t_1);
6975
6976         /* "ctabix.pyx":679
6977  *             conf_data = preset2conf[preset]
6978  *         except KeyError:
6979  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))             # <<<<<<<<<<<<<<
6980  *     else:
6981  *         if end_col == None: end_col = -1
6982  */
6983         __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_48), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
6984         __Pyx_GOTREF(__pyx_t_2);
6985         __pyx_t_12 = PyDict_Keys(__pyx_v_preset2conf); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
6986         __Pyx_GOTREF(__pyx_t_12);
6987         __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
6988         __Pyx_GOTREF(__pyx_t_13);
6989         PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12);
6990         __Pyx_GIVEREF(__pyx_t_12);
6991         __pyx_t_12 = 0;
6992         __pyx_t_12 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
6993         __Pyx_GOTREF(__pyx_t_12);
6994         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6995         __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
6996         __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
6997         __Pyx_GOTREF(__pyx_t_13);
6998         __Pyx_INCREF(__pyx_v_preset);
6999         PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_preset);
7000         __Pyx_GIVEREF(__pyx_v_preset);
7001         PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
7002         __Pyx_GIVEREF(__pyx_t_12);
7003         __pyx_t_12 = 0;
7004         __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), ((PyObject *)__pyx_t_13)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
7005         __Pyx_GOTREF(((PyObject *)__pyx_t_12));
7006         __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
7007         __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
7008         __Pyx_GOTREF(__pyx_t_13);
7009         PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_t_12));
7010         __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
7011         __pyx_t_12 = 0;
7012         __pyx_t_12 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
7013         __Pyx_GOTREF(__pyx_t_12);
7014         __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
7015         __Pyx_Raise(__pyx_t_12, 0, 0, 0);
7016         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
7017         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
7018         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7019         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7020         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7021         goto __pyx_L8_exception_handled;
7022       }
7023       __pyx_L9_except_error:;
7024       __Pyx_XGIVEREF(__pyx_t_8);
7025       __Pyx_XGIVEREF(__pyx_t_9);
7026       __Pyx_XGIVEREF(__pyx_t_10);
7027       __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
7028       goto __pyx_L1_error;
7029       __pyx_L8_exception_handled:;
7030       __Pyx_XGIVEREF(__pyx_t_8);
7031       __Pyx_XGIVEREF(__pyx_t_9);
7032       __Pyx_XGIVEREF(__pyx_t_10);
7033       __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
7034       __pyx_L14_try_end:;
7035     }
7036     goto __pyx_L6;
7037   }
7038   /*else*/ {
7039
7040     /* "ctabix.pyx":681
7041  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
7042  *     else:
7043  *         if end_col == None: end_col = -1             # <<<<<<<<<<<<<<
7044  *         preset = 0
7045  * 
7046  */
7047     __pyx_t_1 = PyObject_RichCompare(__pyx_v_end_col, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7048     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7049     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7050     if (__pyx_t_7) {
7051       __Pyx_INCREF(__pyx_int_neg_1);
7052       __Pyx_DECREF(__pyx_v_end_col);
7053       __pyx_v_end_col = __pyx_int_neg_1;
7054       goto __pyx_L17;
7055     }
7056     __pyx_L17:;
7057
7058     /* "ctabix.pyx":682
7059  *     else:
7060  *         if end_col == None: end_col = -1
7061  *         preset = 0             # <<<<<<<<<<<<<<
7062  * 
7063  *         # note that tabix internally works with 0-based coordinates and open/closed intervals.
7064  */
7065     __Pyx_INCREF(__pyx_int_0);
7066     __Pyx_DECREF(__pyx_v_preset);
7067     __pyx_v_preset = __pyx_int_0;
7068
7069     /* "ctabix.pyx":689
7070  *         # -1 is subtracted from the start coordinate. To avoid doing this, set
7071  *         # the TI_FLAG_UCSC=0x10000 flag:
7072  *         if zerobased: preset = preset | 0x10000             # <<<<<<<<<<<<<<
7073  * 
7074  *         conf_data = (preset, seq_col+1, start_col+1, end_col+1, ord(meta_char), 0)
7075  */
7076     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_zerobased); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7077     if (__pyx_t_7) {
7078       __pyx_t_1 = PyNumber_Or(__pyx_v_preset, __pyx_int_65536); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7079       __Pyx_GOTREF(__pyx_t_1);
7080       __Pyx_DECREF(__pyx_v_preset);
7081       __pyx_v_preset = __pyx_t_1;
7082       __pyx_t_1 = 0;
7083       goto __pyx_L18;
7084     }
7085     __pyx_L18:;
7086
7087     /* "ctabix.pyx":691
7088  *         if zerobased: preset = preset | 0x10000
7089  * 
7090  *         conf_data = (preset, seq_col+1, start_col+1, end_col+1, ord(meta_char), 0)             # <<<<<<<<<<<<<<
7091  * 
7092  *     cdef ti_conf_t conf
7093  */
7094     __pyx_t_1 = PyNumber_Add(__pyx_v_seq_col, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7095     __Pyx_GOTREF(__pyx_t_1);
7096     __pyx_t_3 = PyNumber_Add(__pyx_v_start_col, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7097     __Pyx_GOTREF(__pyx_t_3);
7098     __pyx_t_6 = PyNumber_Add(__pyx_v_end_col, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7099     __Pyx_GOTREF(__pyx_t_6);
7100     __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7101     __Pyx_GOTREF(__pyx_t_12);
7102     __Pyx_INCREF(__pyx_v_meta_char);
7103     PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_meta_char);
7104     __Pyx_GIVEREF(__pyx_v_meta_char);
7105     __pyx_t_13 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7106     __Pyx_GOTREF(__pyx_t_13);
7107     __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
7108     __pyx_t_12 = PyTuple_New(6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7109     __Pyx_GOTREF(__pyx_t_12);
7110     __Pyx_INCREF(__pyx_v_preset);
7111     PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_preset);
7112     __Pyx_GIVEREF(__pyx_v_preset);
7113     PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_1);
7114     __Pyx_GIVEREF(__pyx_t_1);
7115     PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_3);
7116     __Pyx_GIVEREF(__pyx_t_3);
7117     PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_6);
7118     __Pyx_GIVEREF(__pyx_t_6);
7119     PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_t_13);
7120     __Pyx_GIVEREF(__pyx_t_13);
7121     __Pyx_INCREF(__pyx_int_0);
7122     PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_int_0);
7123     __Pyx_GIVEREF(__pyx_int_0);
7124     __pyx_t_1 = 0;
7125     __pyx_t_3 = 0;
7126     __pyx_t_6 = 0;
7127     __pyx_t_13 = 0;
7128     __pyx_v_conf_data = ((PyObject *)__pyx_t_12);
7129     __pyx_t_12 = 0;
7130   }
7131   __pyx_L6:;
7132
7133   /* "ctabix.pyx":694
7134  * 
7135  *     cdef ti_conf_t conf
7136  *     conf.preset, conf.sc, conf.bc, conf.ec, conf.meta_char, conf.line_skip = conf_data             # <<<<<<<<<<<<<<
7137  * 
7138  *     fn = _my_encodeFilename( filename )
7139  */
7140   if ((likely(PyTuple_CheckExact(__pyx_v_conf_data))) || (PyList_CheckExact(__pyx_v_conf_data))) {
7141     PyObject* sequence = __pyx_v_conf_data;
7142     #if CYTHON_COMPILING_IN_CPYTHON
7143     Py_ssize_t size = Py_SIZE(sequence);
7144     #else
7145     Py_ssize_t size = PySequence_Size(sequence);
7146     #endif
7147     if (unlikely(size != 6)) {
7148       if (size > 6) __Pyx_RaiseTooManyValuesError(6);
7149       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
7150       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7151     }
7152     #if CYTHON_COMPILING_IN_CPYTHON
7153     if (likely(PyTuple_CheckExact(sequence))) {
7154       __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
7155       __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
7156       __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
7157       __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
7158       __pyx_t_1 = PyTuple_GET_ITEM(sequence, 4); 
7159       __pyx_t_2 = PyTuple_GET_ITEM(sequence, 5); 
7160     } else {
7161       __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
7162       __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
7163       __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
7164       __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
7165       __pyx_t_1 = PyList_GET_ITEM(sequence, 4); 
7166       __pyx_t_2 = PyList_GET_ITEM(sequence, 5); 
7167     }
7168     __Pyx_INCREF(__pyx_t_12);
7169     __Pyx_INCREF(__pyx_t_13);
7170     __Pyx_INCREF(__pyx_t_6);
7171     __Pyx_INCREF(__pyx_t_3);
7172     __Pyx_INCREF(__pyx_t_1);
7173     __Pyx_INCREF(__pyx_t_2);
7174     #else
7175     Py_ssize_t i;
7176     PyObject** temps[6] = {&__pyx_t_12,&__pyx_t_13,&__pyx_t_6,&__pyx_t_3,&__pyx_t_1,&__pyx_t_2};
7177     for (i=0; i < 6; i++) {
7178       PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7179       *(temps[i]) = item;
7180     }
7181     #endif
7182   } else
7183   {
7184     Py_ssize_t index = -1;
7185     PyObject** temps[6] = {&__pyx_t_12,&__pyx_t_13,&__pyx_t_6,&__pyx_t_3,&__pyx_t_1,&__pyx_t_2};
7186     __pyx_t_14 = PyObject_GetIter(__pyx_v_conf_data); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7187     __Pyx_GOTREF(__pyx_t_14);
7188     __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
7189     for (index=0; index < 6; index++) {
7190       PyObject* item = __pyx_t_15(__pyx_t_14); if (unlikely(!item)) goto __pyx_L19_unpacking_failed;
7191       __Pyx_GOTREF(item);
7192       *(temps[index]) = item;
7193     }
7194     if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7195     __pyx_t_15 = NULL;
7196     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
7197     goto __pyx_L20_unpacking_done;
7198     __pyx_L19_unpacking_failed:;
7199     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
7200     __pyx_t_15 = NULL;
7201     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
7202     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7203     __pyx_L20_unpacking_done:;
7204   }
7205   __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_12); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7206   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
7207   __pyx_t_17 = __Pyx_PyInt_from_py_int32_t(__pyx_t_13); if (unlikely((__pyx_t_17 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7208   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7209   __pyx_t_18 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_18 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7210   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7211   __pyx_t_19 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_19 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7212   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7213   __pyx_t_20 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_20 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7214   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7215   __pyx_t_21 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_21 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7216   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7217   __pyx_v_conf.preset = __pyx_t_16;
7218   __pyx_v_conf.sc = __pyx_t_17;
7219   __pyx_v_conf.bc = __pyx_t_18;
7220   __pyx_v_conf.ec = __pyx_t_19;
7221   __pyx_v_conf.meta_char = __pyx_t_20;
7222   __pyx_v_conf.line_skip = __pyx_t_21;
7223
7224   /* "ctabix.pyx":696
7225  *     conf.preset, conf.sc, conf.bc, conf.ec, conf.meta_char, conf.line_skip = conf_data
7226  * 
7227  *     fn = _my_encodeFilename( filename )             # <<<<<<<<<<<<<<
7228  *     ti_index_build( fn, &conf)
7229  * 
7230  */
7231   __pyx_t_2 = ((PyObject *)__pyx_f_6ctabix__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7232   __Pyx_GOTREF(__pyx_t_2);
7233   __pyx_v_fn = ((PyObject*)__pyx_t_2);
7234   __pyx_t_2 = 0;
7235
7236   /* "ctabix.pyx":697
7237  * 
7238  *     fn = _my_encodeFilename( filename )
7239  *     ti_index_build( fn, &conf)             # <<<<<<<<<<<<<<
7240  * 
7241  *     return filename
7242  */
7243   __pyx_t_22 = PyBytes_AsString(((PyObject *)__pyx_v_fn)); if (unlikely((!__pyx_t_22) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7244   ti_index_build(__pyx_t_22, (&__pyx_v_conf));
7245
7246   /* "ctabix.pyx":699
7247  *     ti_index_build( fn, &conf)
7248  * 
7249  *     return filename             # <<<<<<<<<<<<<<
7250  * 
7251  * #########################################################
7252  */
7253   __Pyx_XDECREF(__pyx_r);
7254   __Pyx_INCREF(__pyx_v_filename);
7255   __pyx_r = __pyx_v_filename;
7256   goto __pyx_L0;
7257
7258   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7259   goto __pyx_L0;
7260   __pyx_L1_error:;
7261   __Pyx_XDECREF(__pyx_t_1);
7262   __Pyx_XDECREF(__pyx_t_2);
7263   __Pyx_XDECREF(__pyx_t_3);
7264   __Pyx_XDECREF(__pyx_t_6);
7265   __Pyx_XDECREF(__pyx_t_12);
7266   __Pyx_XDECREF(__pyx_t_13);
7267   __Pyx_XDECREF(__pyx_t_14);
7268   __Pyx_AddTraceback("ctabix.tabix_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
7269   __pyx_r = NULL;
7270   __pyx_L0:;
7271   __Pyx_XDECREF(__pyx_v_preset2conf);
7272   __Pyx_XDECREF(__pyx_v_conf_data);
7273   __Pyx_XDECREF(__pyx_v_fn);
7274   __Pyx_XDECREF(__pyx_v_filename);
7275   __Pyx_XDECREF(__pyx_v_end_col);
7276   __Pyx_XDECREF(__pyx_v_preset);
7277   __Pyx_XGIVEREF(__pyx_r);
7278   __Pyx_RefNannyFinishContext();
7279   return __pyx_r;
7280 }
7281
7282 /* Python wrapper */
7283 static int __pyx_pw_6ctabix_22tabix_inplace_iterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7284 static int __pyx_pw_6ctabix_22tabix_inplace_iterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7285   PyObject *__pyx_v_infile = 0;
7286   int __pyx_v_buffer_size;
7287   int __pyx_r;
7288   __Pyx_RefNannyDeclarations
7289   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
7290   {
7291     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__infile,&__pyx_n_s__buffer_size,0};
7292     PyObject* values[2] = {0,0};
7293     if (unlikely(__pyx_kwds)) {
7294       Py_ssize_t kw_args;
7295       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7296       switch (pos_args) {
7297         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7298         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7299         case  0: break;
7300         default: goto __pyx_L5_argtuple_error;
7301       }
7302       kw_args = PyDict_Size(__pyx_kwds);
7303       switch (pos_args) {
7304         case  0:
7305         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile)) != 0)) kw_args--;
7306         else goto __pyx_L5_argtuple_error;
7307         case  1:
7308         if (kw_args > 0) {
7309           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer_size);
7310           if (value) { values[1] = value; kw_args--; }
7311         }
7312       }
7313       if (unlikely(kw_args > 0)) {
7314         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
7315       }
7316     } else {
7317       switch (PyTuple_GET_SIZE(__pyx_args)) {
7318         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7319         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7320         break;
7321         default: goto __pyx_L5_argtuple_error;
7322       }
7323     }
7324     __pyx_v_infile = values[0];
7325     if (values[1]) {
7326       __pyx_v_buffer_size = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_buffer_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
7327     } else {
7328       __pyx_v_buffer_size = ((int)65536);
7329     }
7330   }
7331   goto __pyx_L4_argument_unpacking_done;
7332   __pyx_L5_argtuple_error:;
7333   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
7334   __pyx_L3_error:;
7335   __Pyx_AddTraceback("ctabix.tabix_inplace_iterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7336   __Pyx_RefNannyFinishContext();
7337   return -1;
7338   __pyx_L4_argument_unpacking_done:;
7339   __pyx_r = __pyx_pf_6ctabix_22tabix_inplace_iterator___cinit__(((struct __pyx_obj_6ctabix_tabix_inplace_iterator *)__pyx_v_self), __pyx_v_infile, __pyx_v_buffer_size);
7340   __Pyx_RefNannyFinishContext();
7341   return __pyx_r;
7342 }
7343
7344 /* "ctabix.pyx":716
7345  * 
7346  * 
7347  *     def __cinit__(self, infile, int buffer_size = 65536 ):             # <<<<<<<<<<<<<<
7348  * 
7349  *         cdef int fd = PyObject_AsFileDescriptor( infile )
7350  */
7351
7352 static int __pyx_pf_6ctabix_22tabix_inplace_iterator___cinit__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self, PyObject *__pyx_v_infile, int __pyx_v_buffer_size) {
7353   int __pyx_v_fd;
7354   int __pyx_r;
7355   __Pyx_RefNannyDeclarations
7356   int __pyx_t_1;
7357   int __pyx_t_2;
7358   PyObject *__pyx_t_3 = NULL;
7359   int __pyx_lineno = 0;
7360   const char *__pyx_filename = NULL;
7361   int __pyx_clineno = 0;
7362   __Pyx_RefNannySetupContext("__cinit__", 0);
7363
7364   /* "ctabix.pyx":718
7365  *     def __cinit__(self, infile, int buffer_size = 65536 ):
7366  * 
7367  *         cdef int fd = PyObject_AsFileDescriptor( infile )             # <<<<<<<<<<<<<<
7368  *         if fd == -1: raise ValueError( "I/O operation on closed file." )
7369  *         self.infile = fdopen( fd, 'r')
7370  */
7371   __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_infile); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7372   __pyx_v_fd = __pyx_t_1;
7373
7374   /* "ctabix.pyx":719
7375  * 
7376  *         cdef int fd = PyObject_AsFileDescriptor( infile )
7377  *         if fd == -1: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
7378  *         self.infile = fdopen( fd, 'r')
7379  * 
7380  */
7381   __pyx_t_2 = (__pyx_v_fd == -1);
7382   if (__pyx_t_2) {
7383     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7384     __Pyx_GOTREF(__pyx_t_3);
7385     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7386     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7387     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7388     goto __pyx_L3;
7389   }
7390   __pyx_L3:;
7391
7392   /* "ctabix.pyx":720
7393  *         cdef int fd = PyObject_AsFileDescriptor( infile )
7394  *         if fd == -1: raise ValueError( "I/O operation on closed file." )
7395  *         self.infile = fdopen( fd, 'r')             # <<<<<<<<<<<<<<
7396  * 
7397  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )
7398  */
7399   __pyx_v_self->infile = fdopen(__pyx_v_fd, __pyx_k__r);
7400
7401   /* "ctabix.pyx":722
7402  *         self.infile = fdopen( fd, 'r')
7403  * 
7404  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
7405  * 
7406  *         self.buffer = <char*>malloc( buffer_size )
7407  */
7408   __pyx_t_2 = (__pyx_v_self->infile == NULL);
7409   if (__pyx_t_2) {
7410     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7411     __Pyx_GOTREF(__pyx_t_3);
7412     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7413     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7414     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7415     goto __pyx_L4;
7416   }
7417   __pyx_L4:;
7418
7419   /* "ctabix.pyx":724
7420  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )
7421  * 
7422  *         self.buffer = <char*>malloc( buffer_size )             # <<<<<<<<<<<<<<
7423  *         self.size = buffer_size
7424  * 
7425  */
7426   __pyx_v_self->buffer = ((char *)malloc(__pyx_v_buffer_size));
7427
7428   /* "ctabix.pyx":725
7429  * 
7430  *         self.buffer = <char*>malloc( buffer_size )
7431  *         self.size = buffer_size             # <<<<<<<<<<<<<<
7432  * 
7433  *     def __iter__(self):
7434  */
7435   __pyx_v_self->size = __pyx_v_buffer_size;
7436
7437   __pyx_r = 0;
7438   goto __pyx_L0;
7439   __pyx_L1_error:;
7440   __Pyx_XDECREF(__pyx_t_3);
7441   __Pyx_AddTraceback("ctabix.tabix_inplace_iterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7442   __pyx_r = -1;
7443   __pyx_L0:;
7444   __Pyx_RefNannyFinishContext();
7445   return __pyx_r;
7446 }
7447
7448 /* Python wrapper */
7449 static PyObject *__pyx_pw_6ctabix_22tabix_inplace_iterator_3__iter__(PyObject *__pyx_v_self); /*proto*/
7450 static PyObject *__pyx_pw_6ctabix_22tabix_inplace_iterator_3__iter__(PyObject *__pyx_v_self) {
7451   PyObject *__pyx_r = 0;
7452   __Pyx_RefNannyDeclarations
7453   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
7454   __pyx_r = __pyx_pf_6ctabix_22tabix_inplace_iterator_2__iter__(((struct __pyx_obj_6ctabix_tabix_inplace_iterator *)__pyx_v_self));
7455   __Pyx_RefNannyFinishContext();
7456   return __pyx_r;
7457 }
7458
7459 /* "ctabix.pyx":727
7460  *         self.size = buffer_size
7461  * 
7462  *     def __iter__(self):             # <<<<<<<<<<<<<<
7463  *         return self
7464  * 
7465  */
7466
7467 static PyObject *__pyx_pf_6ctabix_22tabix_inplace_iterator_2__iter__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self) {
7468   PyObject *__pyx_r = NULL;
7469   __Pyx_RefNannyDeclarations
7470   __Pyx_RefNannySetupContext("__iter__", 0);
7471
7472   /* "ctabix.pyx":728
7473  * 
7474  *     def __iter__(self):
7475  *         return self             # <<<<<<<<<<<<<<
7476  * 
7477  *     cdef __cnext__(self):
7478  */
7479   __Pyx_XDECREF(__pyx_r);
7480   __Pyx_INCREF(((PyObject *)__pyx_v_self));
7481   __pyx_r = ((PyObject *)__pyx_v_self);
7482   goto __pyx_L0;
7483
7484   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7485   __pyx_L0:;
7486   __Pyx_XGIVEREF(__pyx_r);
7487   __Pyx_RefNannyFinishContext();
7488   return __pyx_r;
7489 }
7490
7491 /* "ctabix.pyx":730
7492  *         return self
7493  * 
7494  *     cdef __cnext__(self):             # <<<<<<<<<<<<<<
7495  * 
7496  *         cdef char * b
7497  */
7498
7499 static PyObject *__pyx_f_6ctabix_22tabix_inplace_iterator___cnext__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self) {
7500   char *__pyx_v_b;
7501   size_t __pyx_v_nbytes;
7502   PyObject *__pyx_v_r = NULL;
7503   char *__pyx_v_result;
7504   PyObject *__pyx_r = NULL;
7505   __Pyx_RefNannyDeclarations
7506   PyObject *__pyx_t_1 = NULL;
7507   PyObject *__pyx_t_2 = NULL;
7508   int __pyx_t_3;
7509   int __pyx_t_4;
7510   int __pyx_t_5;
7511   int __pyx_t_6;
7512   PyObject *__pyx_t_7 = NULL;
7513   PyObject *__pyx_t_8 = NULL;
7514   int __pyx_lineno = 0;
7515   const char *__pyx_filename = NULL;
7516   int __pyx_clineno = 0;
7517   __Pyx_RefNannySetupContext("__cnext__", 0);
7518
7519   /* "ctabix.pyx":734
7520  *         cdef char * b
7521  *         cdef size_t nbytes
7522  *         b = self.buffer             # <<<<<<<<<<<<<<
7523  *         r = self.Parser()
7524  * 
7525  */
7526   __pyx_v_b = __pyx_v_self->buffer;
7527
7528   /* "ctabix.pyx":735
7529  *         cdef size_t nbytes
7530  *         b = self.buffer
7531  *         r = self.Parser()             # <<<<<<<<<<<<<<
7532  * 
7533  *         while not feof( self.infile ):
7534  */
7535   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__Parser); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7536   __Pyx_GOTREF(__pyx_t_1);
7537   __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 = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7538   __Pyx_GOTREF(__pyx_t_2);
7539   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7540   __pyx_v_r = __pyx_t_2;
7541   __pyx_t_2 = 0;
7542
7543   /* "ctabix.pyx":737
7544  *         r = self.Parser()
7545  * 
7546  *         while not feof( self.infile ):             # <<<<<<<<<<<<<<
7547  *             nbytes = getline( &b, &self.size, self.infile)
7548  * 
7549  */
7550   while (1) {
7551     __pyx_t_3 = (!feof(__pyx_v_self->infile));
7552     if (!__pyx_t_3) break;
7553
7554     /* "ctabix.pyx":738
7555  * 
7556  *         while not feof( self.infile ):
7557  *             nbytes = getline( &b, &self.size, self.infile)             # <<<<<<<<<<<<<<
7558  * 
7559  *             # stop at first error or eof
7560  */
7561     __pyx_v_nbytes = getline((&__pyx_v_b), (&__pyx_v_self->size), __pyx_v_self->infile);
7562
7563     /* "ctabix.pyx":741
7564  * 
7565  *             # stop at first error or eof
7566  *             if (nbytes == -1): break             # <<<<<<<<<<<<<<
7567  *             # skip comments
7568  *             if (b[0] == '#'): continue
7569  */
7570     __pyx_t_3 = (__pyx_v_nbytes == -1);
7571     if (__pyx_t_3) {
7572       goto __pyx_L4_break;
7573       goto __pyx_L5;
7574     }
7575     __pyx_L5:;
7576
7577     /* "ctabix.pyx":743
7578  *             if (nbytes == -1): break
7579  *             # skip comments
7580  *             if (b[0] == '#'): continue             # <<<<<<<<<<<<<<
7581  * 
7582  *             # skip empty lines
7583  */
7584     __pyx_t_3 = ((__pyx_v_b[0]) == '#');
7585     if (__pyx_t_3) {
7586       goto __pyx_L3_continue;
7587       goto __pyx_L6;
7588     }
7589     __pyx_L6:;
7590
7591     /* "ctabix.pyx":746
7592  * 
7593  *             # skip empty lines
7594  *             if b[0] == '\0' or b[0] == '\n' or b[0] == '\r': continue             # <<<<<<<<<<<<<<
7595  * 
7596  *             # make sure that entry is complete
7597  */
7598     __pyx_t_3 = ((__pyx_v_b[0]) == '\x00');
7599     if (!__pyx_t_3) {
7600       __pyx_t_4 = ((__pyx_v_b[0]) == '\n');
7601       if (!__pyx_t_4) {
7602         __pyx_t_5 = ((__pyx_v_b[0]) == '\r');
7603         __pyx_t_6 = __pyx_t_5;
7604       } else {
7605         __pyx_t_6 = __pyx_t_4;
7606       }
7607       __pyx_t_4 = __pyx_t_6;
7608     } else {
7609       __pyx_t_4 = __pyx_t_3;
7610     }
7611     if (__pyx_t_4) {
7612       goto __pyx_L3_continue;
7613       goto __pyx_L7;
7614     }
7615     __pyx_L7:;
7616
7617     /* "ctabix.pyx":749
7618  * 
7619  *             # make sure that entry is complete
7620  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':             # <<<<<<<<<<<<<<
7621  *                 result = b
7622  *                 raise ValueError( "incomplete line at %s" % result )
7623  */
7624     __pyx_t_4 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\n');
7625     if (__pyx_t_4) {
7626       __pyx_t_3 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\r');
7627       __pyx_t_6 = __pyx_t_3;
7628     } else {
7629       __pyx_t_6 = __pyx_t_4;
7630     }
7631     if (__pyx_t_6) {
7632
7633       /* "ctabix.pyx":750
7634  *             # make sure that entry is complete
7635  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':
7636  *                 result = b             # <<<<<<<<<<<<<<
7637  *                 raise ValueError( "incomplete line at %s" % result )
7638  * 
7639  */
7640       __pyx_v_result = __pyx_v_b;
7641
7642       /* "ctabix.pyx":751
7643  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':
7644  *                 result = b
7645  *                 raise ValueError( "incomplete line at %s" % result )             # <<<<<<<<<<<<<<
7646  * 
7647  *             # make sure that this goes fully through C
7648  */
7649       __pyx_t_2 = PyBytes_FromString(__pyx_v_result); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7650       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
7651       __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7652       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
7653       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
7654       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7655       __Pyx_GOTREF(__pyx_t_2);
7656       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
7657       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
7658       __pyx_t_1 = 0;
7659       __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7660       __Pyx_GOTREF(__pyx_t_1);
7661       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
7662       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
7663       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7664       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7665       goto __pyx_L8;
7666     }
7667     __pyx_L8:;
7668
7669     /* "ctabix.pyx":757
7670  *             # Python object causing segfaults as
7671  *             # the wrong memory is freed
7672  *             r.present( b, nbytes )             # <<<<<<<<<<<<<<
7673  *             return r
7674  * 
7675  */
7676     __pyx_t_1 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__present); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7677     __Pyx_GOTREF(__pyx_t_1);
7678     __pyx_t_2 = PyBytes_FromString(__pyx_v_b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7679     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
7680     __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7681     __Pyx_GOTREF(__pyx_t_7);
7682     __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7683     __Pyx_GOTREF(__pyx_t_8);
7684     PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_2));
7685     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
7686     PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
7687     __Pyx_GIVEREF(__pyx_t_7);
7688     __pyx_t_2 = 0;
7689     __pyx_t_7 = 0;
7690     __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7691     __Pyx_GOTREF(__pyx_t_7);
7692     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7693     __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
7694     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7695
7696     /* "ctabix.pyx":758
7697  *             # the wrong memory is freed
7698  *             r.present( b, nbytes )
7699  *             return r             # <<<<<<<<<<<<<<
7700  * 
7701  *         raise StopIteration
7702  */
7703     __Pyx_XDECREF(__pyx_r);
7704     __Pyx_INCREF(__pyx_v_r);
7705     __pyx_r = __pyx_v_r;
7706     goto __pyx_L0;
7707     __pyx_L3_continue:;
7708   }
7709   __pyx_L4_break:;
7710
7711   /* "ctabix.pyx":760
7712  *             return r
7713  * 
7714  *         raise StopIteration             # <<<<<<<<<<<<<<
7715  * 
7716  *     def __dealloc__(self):
7717  */
7718   __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
7719   {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7720
7721   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7722   goto __pyx_L0;
7723   __pyx_L1_error:;
7724   __Pyx_XDECREF(__pyx_t_1);
7725   __Pyx_XDECREF(__pyx_t_2);
7726   __Pyx_XDECREF(__pyx_t_7);
7727   __Pyx_XDECREF(__pyx_t_8);
7728   __Pyx_AddTraceback("ctabix.tabix_inplace_iterator.__cnext__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7729   __pyx_r = 0;
7730   __pyx_L0:;
7731   __Pyx_XDECREF(__pyx_v_r);
7732   __Pyx_XGIVEREF(__pyx_r);
7733   __Pyx_RefNannyFinishContext();
7734   return __pyx_r;
7735 }
7736
7737 /* Python wrapper */
7738 static void __pyx_pw_6ctabix_22tabix_inplace_iterator_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
7739 static void __pyx_pw_6ctabix_22tabix_inplace_iterator_5__dealloc__(PyObject *__pyx_v_self) {
7740   __Pyx_RefNannyDeclarations
7741   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
7742   __pyx_pf_6ctabix_22tabix_inplace_iterator_4__dealloc__(((struct __pyx_obj_6ctabix_tabix_inplace_iterator *)__pyx_v_self));
7743   __Pyx_RefNannyFinishContext();
7744 }
7745
7746 /* "ctabix.pyx":762
7747  *         raise StopIteration
7748  * 
7749  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
7750  *         free(self.buffer)
7751  * 
7752  */
7753
7754 static void __pyx_pf_6ctabix_22tabix_inplace_iterator_4__dealloc__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self) {
7755   __Pyx_RefNannyDeclarations
7756   __Pyx_RefNannySetupContext("__dealloc__", 0);
7757
7758   /* "ctabix.pyx":763
7759  * 
7760  *     def __dealloc__(self):
7761  *         free(self.buffer)             # <<<<<<<<<<<<<<
7762  * 
7763  *     def __next__(self):
7764  */
7765   free(__pyx_v_self->buffer);
7766
7767   __Pyx_RefNannyFinishContext();
7768 }
7769
7770 /* Python wrapper */
7771 static PyObject *__pyx_pw_6ctabix_22tabix_inplace_iterator_7__next__(PyObject *__pyx_v_self); /*proto*/
7772 static PyObject *__pyx_pw_6ctabix_22tabix_inplace_iterator_7__next__(PyObject *__pyx_v_self) {
7773   PyObject *__pyx_r = 0;
7774   __Pyx_RefNannyDeclarations
7775   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
7776   __pyx_r = __pyx_pf_6ctabix_22tabix_inplace_iterator_6__next__(((struct __pyx_obj_6ctabix_tabix_inplace_iterator *)__pyx_v_self));
7777   __Pyx_RefNannyFinishContext();
7778   return __pyx_r;
7779 }
7780
7781 /* "ctabix.pyx":765
7782  *         free(self.buffer)
7783  * 
7784  *     def __next__(self):             # <<<<<<<<<<<<<<
7785  *         return self.__cnext__()
7786  * 
7787  */
7788
7789 static PyObject *__pyx_pf_6ctabix_22tabix_inplace_iterator_6__next__(struct __pyx_obj_6ctabix_tabix_inplace_iterator *__pyx_v_self) {
7790   PyObject *__pyx_r = NULL;
7791   __Pyx_RefNannyDeclarations
7792   PyObject *__pyx_t_1 = NULL;
7793   int __pyx_lineno = 0;
7794   const char *__pyx_filename = NULL;
7795   int __pyx_clineno = 0;
7796   __Pyx_RefNannySetupContext("__next__", 0);
7797
7798   /* "ctabix.pyx":766
7799  * 
7800  *     def __next__(self):
7801  *         return self.__cnext__()             # <<<<<<<<<<<<<<
7802  * 
7803  * ctypedef class tabix_copy_iterator:
7804  */
7805   __Pyx_XDECREF(__pyx_r);
7806   __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_tabix_inplace_iterator *)__pyx_v_self->__pyx_vtab)->__pyx___cnext__(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7807   __Pyx_GOTREF(__pyx_t_1);
7808   __pyx_r = __pyx_t_1;
7809   __pyx_t_1 = 0;
7810   goto __pyx_L0;
7811
7812   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7813   goto __pyx_L0;
7814   __pyx_L1_error:;
7815   __Pyx_XDECREF(__pyx_t_1);
7816   __Pyx_AddTraceback("ctabix.tabix_inplace_iterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7817   __pyx_r = NULL;
7818   __pyx_L0:;
7819   __Pyx_XGIVEREF(__pyx_r);
7820   __Pyx_RefNannyFinishContext();
7821   return __pyx_r;
7822 }
7823
7824 /* Python wrapper */
7825 static int __pyx_pw_6ctabix_19tabix_copy_iterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7826 static int __pyx_pw_6ctabix_19tabix_copy_iterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7827   PyObject *__pyx_v_infile = 0;
7828   struct __pyx_obj_6ctabix_Parser *__pyx_v_parser = 0;
7829   int __pyx_r;
7830   __Pyx_RefNannyDeclarations
7831   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
7832   {
7833     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__infile,&__pyx_n_s__parser,0};
7834     PyObject* values[2] = {0,0};
7835     if (unlikely(__pyx_kwds)) {
7836       Py_ssize_t kw_args;
7837       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7838       switch (pos_args) {
7839         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7840         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7841         case  0: break;
7842         default: goto __pyx_L5_argtuple_error;
7843       }
7844       kw_args = PyDict_Size(__pyx_kwds);
7845       switch (pos_args) {
7846         case  0:
7847         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile)) != 0)) kw_args--;
7848         else goto __pyx_L5_argtuple_error;
7849         case  1:
7850         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser)) != 0)) kw_args--;
7851         else {
7852           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
7853         }
7854       }
7855       if (unlikely(kw_args > 0)) {
7856         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
7857       }
7858     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
7859       goto __pyx_L5_argtuple_error;
7860     } else {
7861       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7862       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7863     }
7864     __pyx_v_infile = values[0];
7865     __pyx_v_parser = ((struct __pyx_obj_6ctabix_Parser *)values[1]);
7866   }
7867   goto __pyx_L4_argument_unpacking_done;
7868   __pyx_L5_argtuple_error:;
7869   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
7870   __pyx_L3_error:;
7871   __Pyx_AddTraceback("ctabix.tabix_copy_iterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7872   __Pyx_RefNannyFinishContext();
7873   return -1;
7874   __pyx_L4_argument_unpacking_done:;
7875   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_6ctabix_Parser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7876   __pyx_r = __pyx_pf_6ctabix_19tabix_copy_iterator___cinit__(((struct __pyx_obj_6ctabix_tabix_copy_iterator *)__pyx_v_self), __pyx_v_infile, __pyx_v_parser);
7877   goto __pyx_L0;
7878   __pyx_L1_error:;
7879   __pyx_r = -1;
7880   __pyx_L0:;
7881   __Pyx_RefNannyFinishContext();
7882   return __pyx_r;
7883 }
7884
7885 /* "ctabix.pyx":777
7886  *     '''
7887  * 
7888  *     def __cinit__(self, infile, Parser parser ):             # <<<<<<<<<<<<<<
7889  * 
7890  *         cdef int fd = PyObject_AsFileDescriptor( infile )
7891  */
7892
7893 static int __pyx_pf_6ctabix_19tabix_copy_iterator___cinit__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self, PyObject *__pyx_v_infile, struct __pyx_obj_6ctabix_Parser *__pyx_v_parser) {
7894   int __pyx_v_fd;
7895   int __pyx_r;
7896   __Pyx_RefNannyDeclarations
7897   int __pyx_t_1;
7898   int __pyx_t_2;
7899   PyObject *__pyx_t_3 = NULL;
7900   int __pyx_lineno = 0;
7901   const char *__pyx_filename = NULL;
7902   int __pyx_clineno = 0;
7903   __Pyx_RefNannySetupContext("__cinit__", 0);
7904
7905   /* "ctabix.pyx":779
7906  *     def __cinit__(self, infile, Parser parser ):
7907  * 
7908  *         cdef int fd = PyObject_AsFileDescriptor( infile )             # <<<<<<<<<<<<<<
7909  *         if fd == -1: raise ValueError( "I/O operation on closed file." )
7910  *         self.infile = fdopen( fd, 'r')
7911  */
7912   __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_infile); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7913   __pyx_v_fd = __pyx_t_1;
7914
7915   /* "ctabix.pyx":780
7916  * 
7917  *         cdef int fd = PyObject_AsFileDescriptor( infile )
7918  *         if fd == -1: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
7919  *         self.infile = fdopen( fd, 'r')
7920  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )
7921  */
7922   __pyx_t_2 = (__pyx_v_fd == -1);
7923   if (__pyx_t_2) {
7924     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_53), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7925     __Pyx_GOTREF(__pyx_t_3);
7926     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7927     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7928     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7929     goto __pyx_L3;
7930   }
7931   __pyx_L3:;
7932
7933   /* "ctabix.pyx":781
7934  *         cdef int fd = PyObject_AsFileDescriptor( infile )
7935  *         if fd == -1: raise ValueError( "I/O operation on closed file." )
7936  *         self.infile = fdopen( fd, 'r')             # <<<<<<<<<<<<<<
7937  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )
7938  *         self.parser = parser
7939  */
7940   __pyx_v_self->infile = fdopen(__pyx_v_fd, __pyx_k__r);
7941
7942   /* "ctabix.pyx":782
7943  *         if fd == -1: raise ValueError( "I/O operation on closed file." )
7944  *         self.infile = fdopen( fd, 'r')
7945  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
7946  *         self.parser = parser
7947  * 
7948  */
7949   __pyx_t_2 = (__pyx_v_self->infile == NULL);
7950   if (__pyx_t_2) {
7951     __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_54), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7952     __Pyx_GOTREF(__pyx_t_3);
7953     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7954     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7955     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7956     goto __pyx_L4;
7957   }
7958   __pyx_L4:;
7959
7960   /* "ctabix.pyx":783
7961  *         self.infile = fdopen( fd, 'r')
7962  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )
7963  *         self.parser = parser             # <<<<<<<<<<<<<<
7964  * 
7965  *     def __iter__(self):
7966  */
7967   __Pyx_INCREF(((PyObject *)__pyx_v_parser));
7968   __Pyx_GIVEREF(((PyObject *)__pyx_v_parser));
7969   __Pyx_GOTREF(__pyx_v_self->parser);
7970   __Pyx_DECREF(((PyObject *)__pyx_v_self->parser));
7971   __pyx_v_self->parser = __pyx_v_parser;
7972
7973   __pyx_r = 0;
7974   goto __pyx_L0;
7975   __pyx_L1_error:;
7976   __Pyx_XDECREF(__pyx_t_3);
7977   __Pyx_AddTraceback("ctabix.tabix_copy_iterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
7978   __pyx_r = -1;
7979   __pyx_L0:;
7980   __Pyx_RefNannyFinishContext();
7981   return __pyx_r;
7982 }
7983
7984 /* Python wrapper */
7985 static PyObject *__pyx_pw_6ctabix_19tabix_copy_iterator_3__iter__(PyObject *__pyx_v_self); /*proto*/
7986 static PyObject *__pyx_pw_6ctabix_19tabix_copy_iterator_3__iter__(PyObject *__pyx_v_self) {
7987   PyObject *__pyx_r = 0;
7988   __Pyx_RefNannyDeclarations
7989   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
7990   __pyx_r = __pyx_pf_6ctabix_19tabix_copy_iterator_2__iter__(((struct __pyx_obj_6ctabix_tabix_copy_iterator *)__pyx_v_self));
7991   __Pyx_RefNannyFinishContext();
7992   return __pyx_r;
7993 }
7994
7995 /* "ctabix.pyx":785
7996  *         self.parser = parser
7997  * 
7998  *     def __iter__(self):             # <<<<<<<<<<<<<<
7999  *         return self
8000  * 
8001  */
8002
8003 static PyObject *__pyx_pf_6ctabix_19tabix_copy_iterator_2__iter__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self) {
8004   PyObject *__pyx_r = NULL;
8005   __Pyx_RefNannyDeclarations
8006   __Pyx_RefNannySetupContext("__iter__", 0);
8007
8008   /* "ctabix.pyx":786
8009  * 
8010  *     def __iter__(self):
8011  *         return self             # <<<<<<<<<<<<<<
8012  * 
8013  *     cdef __cnext__(self):
8014  */
8015   __Pyx_XDECREF(__pyx_r);
8016   __Pyx_INCREF(((PyObject *)__pyx_v_self));
8017   __pyx_r = ((PyObject *)__pyx_v_self);
8018   goto __pyx_L0;
8019
8020   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8021   __pyx_L0:;
8022   __Pyx_XGIVEREF(__pyx_r);
8023   __Pyx_RefNannyFinishContext();
8024   return __pyx_r;
8025 }
8026
8027 /* "ctabix.pyx":788
8028  *         return self
8029  * 
8030  *     cdef __cnext__(self):             # <<<<<<<<<<<<<<
8031  * 
8032  *         cdef char * b
8033  */
8034
8035 static PyObject *__pyx_f_6ctabix_19tabix_copy_iterator___cnext__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self) {
8036   char *__pyx_v_b;
8037   size_t __pyx_v_nbytes;
8038   char *__pyx_v_result;
8039   PyObject *__pyx_r = NULL;
8040   __Pyx_RefNannyDeclarations
8041   int __pyx_t_1;
8042   int __pyx_t_2;
8043   int __pyx_t_3;
8044   int __pyx_t_4;
8045   PyObject *__pyx_t_5 = NULL;
8046   PyObject *__pyx_t_6 = NULL;
8047   PyObject *__pyx_t_7 = NULL;
8048   int __pyx_lineno = 0;
8049   const char *__pyx_filename = NULL;
8050   int __pyx_clineno = 0;
8051   __Pyx_RefNannySetupContext("__cnext__", 0);
8052
8053   /* "ctabix.pyx":794
8054  *         cdef int x
8055  * 
8056  *         b = NULL             # <<<<<<<<<<<<<<
8057  * 
8058  *         while not feof( self.infile ):
8059  */
8060   __pyx_v_b = NULL;
8061
8062   /* "ctabix.pyx":796
8063  *         b = NULL
8064  * 
8065  *         while not feof( self.infile ):             # <<<<<<<<<<<<<<
8066  * 
8067  *             # getline allocates on demand
8068  */
8069   while (1) {
8070     __pyx_t_1 = (!feof(__pyx_v_self->infile));
8071     if (!__pyx_t_1) break;
8072
8073     /* "ctabix.pyx":800
8074  *             # getline allocates on demand
8075  *             # return number of characters read excluding null byte
8076  *             nbytes = getline( &b, &nbytes, self.infile)             # <<<<<<<<<<<<<<
8077  *             # stop at first error
8078  *             if (nbytes == -1): break
8079  */
8080     __pyx_v_nbytes = getline((&__pyx_v_b), (&__pyx_v_nbytes), __pyx_v_self->infile);
8081
8082     /* "ctabix.pyx":802
8083  *             nbytes = getline( &b, &nbytes, self.infile)
8084  *             # stop at first error
8085  *             if (nbytes == -1): break             # <<<<<<<<<<<<<<
8086  *             # skip comments
8087  *             if (b[0] == '#'): continue
8088  */
8089     __pyx_t_1 = (__pyx_v_nbytes == -1);
8090     if (__pyx_t_1) {
8091       goto __pyx_L4_break;
8092       goto __pyx_L5;
8093     }
8094     __pyx_L5:;
8095
8096     /* "ctabix.pyx":804
8097  *             if (nbytes == -1): break
8098  *             # skip comments
8099  *             if (b[0] == '#'): continue             # <<<<<<<<<<<<<<
8100  * 
8101  *             # skip empty lines
8102  */
8103     __pyx_t_1 = ((__pyx_v_b[0]) == '#');
8104     if (__pyx_t_1) {
8105       goto __pyx_L3_continue;
8106       goto __pyx_L6;
8107     }
8108     __pyx_L6:;
8109
8110     /* "ctabix.pyx":807
8111  * 
8112  *             # skip empty lines
8113  *             if b[0] == '\0' or b[0] == '\n' or b[0] == '\r': continue             # <<<<<<<<<<<<<<
8114  * 
8115  *             # make sure that entry is complete
8116  */
8117     __pyx_t_1 = ((__pyx_v_b[0]) == '\x00');
8118     if (!__pyx_t_1) {
8119       __pyx_t_2 = ((__pyx_v_b[0]) == '\n');
8120       if (!__pyx_t_2) {
8121         __pyx_t_3 = ((__pyx_v_b[0]) == '\r');
8122         __pyx_t_4 = __pyx_t_3;
8123       } else {
8124         __pyx_t_4 = __pyx_t_2;
8125       }
8126       __pyx_t_2 = __pyx_t_4;
8127     } else {
8128       __pyx_t_2 = __pyx_t_1;
8129     }
8130     if (__pyx_t_2) {
8131       goto __pyx_L3_continue;
8132       goto __pyx_L7;
8133     }
8134     __pyx_L7:;
8135
8136     /* "ctabix.pyx":810
8137  * 
8138  *             # make sure that entry is complete
8139  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':             # <<<<<<<<<<<<<<
8140  *                 result = b
8141  *                 free(b)
8142  */
8143     __pyx_t_2 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\n');
8144     if (__pyx_t_2) {
8145       __pyx_t_1 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\r');
8146       __pyx_t_4 = __pyx_t_1;
8147     } else {
8148       __pyx_t_4 = __pyx_t_2;
8149     }
8150     if (__pyx_t_4) {
8151
8152       /* "ctabix.pyx":811
8153  *             # make sure that entry is complete
8154  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':
8155  *                 result = b             # <<<<<<<<<<<<<<
8156  *                 free(b)
8157  *                 raise ValueError( "incomplete line at %s" % result )
8158  */
8159       __pyx_v_result = __pyx_v_b;
8160
8161       /* "ctabix.pyx":812
8162  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':
8163  *                 result = b
8164  *                 free(b)             # <<<<<<<<<<<<<<
8165  *                 raise ValueError( "incomplete line at %s" % result )
8166  * 
8167  */
8168       free(__pyx_v_b);
8169
8170       /* "ctabix.pyx":813
8171  *                 result = b
8172  *                 free(b)
8173  *                 raise ValueError( "incomplete line at %s" % result )             # <<<<<<<<<<<<<<
8174  * 
8175  *             # make sure that this goes fully through C
8176  */
8177       __pyx_t_5 = PyBytes_FromString(__pyx_v_result); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8178       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
8179       __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8180       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
8181       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
8182       __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8183       __Pyx_GOTREF(__pyx_t_5);
8184       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
8185       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
8186       __pyx_t_6 = 0;
8187       __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 = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8188       __Pyx_GOTREF(__pyx_t_6);
8189       __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
8190       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
8191       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8192       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8193       goto __pyx_L8;
8194     }
8195     __pyx_L8:;
8196
8197     /* "ctabix.pyx":820
8198  *             # the wrong memory is freed
8199  *             # -1 to remove the new-line character
8200  *             return self.parser(b, nbytes)             # <<<<<<<<<<<<<<
8201  * 
8202  *         free(b)
8203  */
8204     __Pyx_XDECREF(__pyx_r);
8205     __pyx_t_6 = PyBytes_FromString(__pyx_v_b); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8206     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
8207     __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8208     __Pyx_GOTREF(__pyx_t_5);
8209     __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8210     __Pyx_GOTREF(__pyx_t_7);
8211     PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
8212     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
8213     PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
8214     __Pyx_GIVEREF(__pyx_t_5);
8215     __pyx_t_6 = 0;
8216     __pyx_t_5 = 0;
8217     __pyx_t_5 = PyObject_Call(((PyObject *)__pyx_v_self->parser), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8218     __Pyx_GOTREF(__pyx_t_5);
8219     __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
8220     __pyx_r = __pyx_t_5;
8221     __pyx_t_5 = 0;
8222     goto __pyx_L0;
8223     __pyx_L3_continue:;
8224   }
8225   __pyx_L4_break:;
8226
8227   /* "ctabix.pyx":822
8228  *             return self.parser(b, nbytes)
8229  * 
8230  *         free(b)             # <<<<<<<<<<<<<<
8231  *         raise StopIteration
8232  * 
8233  */
8234   free(__pyx_v_b);
8235
8236   /* "ctabix.pyx":823
8237  * 
8238  *         free(b)
8239  *         raise StopIteration             # <<<<<<<<<<<<<<
8240  * 
8241  *     def __next__(self):
8242  */
8243   __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
8244   {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8245
8246   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8247   goto __pyx_L0;
8248   __pyx_L1_error:;
8249   __Pyx_XDECREF(__pyx_t_5);
8250   __Pyx_XDECREF(__pyx_t_6);
8251   __Pyx_XDECREF(__pyx_t_7);
8252   __Pyx_AddTraceback("ctabix.tabix_copy_iterator.__cnext__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8253   __pyx_r = 0;
8254   __pyx_L0:;
8255   __Pyx_XGIVEREF(__pyx_r);
8256   __Pyx_RefNannyFinishContext();
8257   return __pyx_r;
8258 }
8259
8260 /* Python wrapper */
8261 static PyObject *__pyx_pw_6ctabix_19tabix_copy_iterator_5__next__(PyObject *__pyx_v_self); /*proto*/
8262 static PyObject *__pyx_pw_6ctabix_19tabix_copy_iterator_5__next__(PyObject *__pyx_v_self) {
8263   PyObject *__pyx_r = 0;
8264   __Pyx_RefNannyDeclarations
8265   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
8266   __pyx_r = __pyx_pf_6ctabix_19tabix_copy_iterator_4__next__(((struct __pyx_obj_6ctabix_tabix_copy_iterator *)__pyx_v_self));
8267   __Pyx_RefNannyFinishContext();
8268   return __pyx_r;
8269 }
8270
8271 /* "ctabix.pyx":825
8272  *         raise StopIteration
8273  * 
8274  *     def __next__(self):             # <<<<<<<<<<<<<<
8275  *         return self.__cnext__()
8276  * 
8277  */
8278
8279 static PyObject *__pyx_pf_6ctabix_19tabix_copy_iterator_4__next__(struct __pyx_obj_6ctabix_tabix_copy_iterator *__pyx_v_self) {
8280   PyObject *__pyx_r = NULL;
8281   __Pyx_RefNannyDeclarations
8282   PyObject *__pyx_t_1 = NULL;
8283   int __pyx_lineno = 0;
8284   const char *__pyx_filename = NULL;
8285   int __pyx_clineno = 0;
8286   __Pyx_RefNannySetupContext("__next__", 0);
8287
8288   /* "ctabix.pyx":826
8289  * 
8290  *     def __next__(self):
8291  *         return self.__cnext__()             # <<<<<<<<<<<<<<
8292  * 
8293  * class tabix_generic_iterator:
8294  */
8295   __Pyx_XDECREF(__pyx_r);
8296   __pyx_t_1 = ((struct __pyx_vtabstruct_6ctabix_tabix_copy_iterator *)__pyx_v_self->__pyx_vtab)->__pyx___cnext__(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8297   __Pyx_GOTREF(__pyx_t_1);
8298   __pyx_r = __pyx_t_1;
8299   __pyx_t_1 = 0;
8300   goto __pyx_L0;
8301
8302   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8303   goto __pyx_L0;
8304   __pyx_L1_error:;
8305   __Pyx_XDECREF(__pyx_t_1);
8306   __Pyx_AddTraceback("ctabix.tabix_copy_iterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8307   __pyx_r = NULL;
8308   __pyx_L0:;
8309   __Pyx_XGIVEREF(__pyx_r);
8310   __Pyx_RefNannyFinishContext();
8311   return __pyx_r;
8312 }
8313
8314 /* Python wrapper */
8315 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8316 static char __pyx_doc_6ctabix_22tabix_generic_iterator___init__[] = "tabix_generic_iterator.__init__(self, infile, parser)";
8317 static PyMethodDef __pyx_mdef_6ctabix_22tabix_generic_iterator_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_6ctabix_22tabix_generic_iterator_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_22tabix_generic_iterator___init__)};
8318 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8319   PyObject *__pyx_v_self = 0;
8320   PyObject *__pyx_v_infile = 0;
8321   PyObject *__pyx_v_parser = 0;
8322   PyObject *__pyx_r = 0;
8323   __Pyx_RefNannyDeclarations
8324   __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
8325   {
8326     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__infile,&__pyx_n_s__parser,0};
8327     PyObject* values[3] = {0,0,0};
8328     if (unlikely(__pyx_kwds)) {
8329       Py_ssize_t kw_args;
8330       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8331       switch (pos_args) {
8332         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8333         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8334         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8335         case  0: break;
8336         default: goto __pyx_L5_argtuple_error;
8337       }
8338       kw_args = PyDict_Size(__pyx_kwds);
8339       switch (pos_args) {
8340         case  0:
8341         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
8342         else goto __pyx_L5_argtuple_error;
8343         case  1:
8344         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile)) != 0)) kw_args--;
8345         else {
8346           __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8347         }
8348         case  2:
8349         if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser)) != 0)) kw_args--;
8350         else {
8351           __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8352         }
8353       }
8354       if (unlikely(kw_args > 0)) {
8355         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8356       }
8357     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
8358       goto __pyx_L5_argtuple_error;
8359     } else {
8360       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8361       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8362       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8363     }
8364     __pyx_v_self = values[0];
8365     __pyx_v_infile = values[1];
8366     __pyx_v_parser = values[2];
8367   }
8368   goto __pyx_L4_argument_unpacking_done;
8369   __pyx_L5_argtuple_error:;
8370   __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8371   __pyx_L3_error:;
8372   __Pyx_AddTraceback("ctabix.tabix_generic_iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8373   __Pyx_RefNannyFinishContext();
8374   return NULL;
8375   __pyx_L4_argument_unpacking_done:;
8376   __pyx_r = __pyx_pf_6ctabix_22tabix_generic_iterator___init__(__pyx_self, __pyx_v_self, __pyx_v_infile, __pyx_v_parser);
8377   __Pyx_RefNannyFinishContext();
8378   return __pyx_r;
8379 }
8380
8381 /* "ctabix.pyx":833
8382  *     Permits the use of file-like objects for example from the gzip module.
8383  *     '''
8384  *     def __init__(self, infile, parser ):             # <<<<<<<<<<<<<<
8385  * 
8386  *         self.infile = infile
8387  */
8388
8389 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_infile, PyObject *__pyx_v_parser) {
8390   PyObject *__pyx_r = NULL;
8391   __Pyx_RefNannyDeclarations
8392   PyObject *__pyx_t_1 = NULL;
8393   PyObject *__pyx_t_2 = NULL;
8394   int __pyx_t_3;
8395   int __pyx_lineno = 0;
8396   const char *__pyx_filename = NULL;
8397   int __pyx_clineno = 0;
8398   __Pyx_RefNannySetupContext("__init__", 0);
8399
8400   /* "ctabix.pyx":835
8401  *     def __init__(self, infile, parser ):
8402  * 
8403  *         self.infile = infile             # <<<<<<<<<<<<<<
8404  *         if self.infile.closed: raise ValueError( "I/O operation on closed file." )
8405  *         self.parser = parser
8406  */
8407   if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__infile, __pyx_v_infile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8408
8409   /* "ctabix.pyx":836
8410  * 
8411  *         self.infile = infile
8412  *         if self.infile.closed: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
8413  *         self.parser = parser
8414  * 
8415  */
8416   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__infile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8417   __Pyx_GOTREF(__pyx_t_1);
8418   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__closed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8419   __Pyx_GOTREF(__pyx_t_2);
8420   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8421   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8422   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8423   if (__pyx_t_3) {
8424     __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_55), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8425     __Pyx_GOTREF(__pyx_t_2);
8426     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
8427     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8428     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8429     goto __pyx_L3;
8430   }
8431   __pyx_L3:;
8432
8433   /* "ctabix.pyx":837
8434  *         self.infile = infile
8435  *         if self.infile.closed: raise ValueError( "I/O operation on closed file." )
8436  *         self.parser = parser             # <<<<<<<<<<<<<<
8437  * 
8438  *     def __iter__(self):
8439  */
8440   if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__parser, __pyx_v_parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8441
8442   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8443   goto __pyx_L0;
8444   __pyx_L1_error:;
8445   __Pyx_XDECREF(__pyx_t_1);
8446   __Pyx_XDECREF(__pyx_t_2);
8447   __Pyx_AddTraceback("ctabix.tabix_generic_iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8448   __pyx_r = NULL;
8449   __pyx_L0:;
8450   __Pyx_XGIVEREF(__pyx_r);
8451   __Pyx_RefNannyFinishContext();
8452   return __pyx_r;
8453 }
8454
8455 /* Python wrapper */
8456 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
8457 static char __pyx_doc_6ctabix_22tabix_generic_iterator_2__iter__[] = "tabix_generic_iterator.__iter__(self)";
8458 static PyMethodDef __pyx_mdef_6ctabix_22tabix_generic_iterator_3__iter__ = {__Pyx_NAMESTR("__iter__"), (PyCFunction)__pyx_pw_6ctabix_22tabix_generic_iterator_3__iter__, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_22tabix_generic_iterator_2__iter__)};
8459 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
8460   PyObject *__pyx_r = 0;
8461   __Pyx_RefNannyDeclarations
8462   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
8463   __pyx_r = __pyx_pf_6ctabix_22tabix_generic_iterator_2__iter__(__pyx_self, ((PyObject *)__pyx_v_self));
8464   __Pyx_RefNannyFinishContext();
8465   return __pyx_r;
8466 }
8467
8468 /* "ctabix.pyx":839
8469  *         self.parser = parser
8470  * 
8471  *     def __iter__(self):             # <<<<<<<<<<<<<<
8472  *         return self
8473  * 
8474  */
8475
8476 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
8477   PyObject *__pyx_r = NULL;
8478   __Pyx_RefNannyDeclarations
8479   __Pyx_RefNannySetupContext("__iter__", 0);
8480
8481   /* "ctabix.pyx":840
8482  * 
8483  *     def __iter__(self):
8484  *         return self             # <<<<<<<<<<<<<<
8485  * 
8486  *     # cython version - required for python 3
8487  */
8488   __Pyx_XDECREF(__pyx_r);
8489   __Pyx_INCREF(__pyx_v_self);
8490   __pyx_r = __pyx_v_self;
8491   goto __pyx_L0;
8492
8493   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8494   __pyx_L0:;
8495   __Pyx_XGIVEREF(__pyx_r);
8496   __Pyx_RefNannyFinishContext();
8497   return __pyx_r;
8498 }
8499
8500 /* Python wrapper */
8501 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_5__next__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
8502 static char __pyx_doc_6ctabix_22tabix_generic_iterator_4__next__[] = "tabix_generic_iterator.__next__(self)";
8503 static PyMethodDef __pyx_mdef_6ctabix_22tabix_generic_iterator_5__next__ = {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6ctabix_22tabix_generic_iterator_5__next__, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_22tabix_generic_iterator_4__next__)};
8504 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_5__next__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
8505   PyObject *__pyx_r = 0;
8506   __Pyx_RefNannyDeclarations
8507   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
8508   __pyx_r = __pyx_pf_6ctabix_22tabix_generic_iterator_4__next__(__pyx_self, ((PyObject *)__pyx_v_self));
8509   __Pyx_RefNannyFinishContext();
8510   return __pyx_r;
8511 }
8512
8513 /* "ctabix.pyx":843
8514  * 
8515  *     # cython version - required for python 3
8516  *     def __next__(self):             # <<<<<<<<<<<<<<
8517  * 
8518  *         cdef char * b, * cpy
8519  */
8520
8521 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator_4__next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
8522   char *__pyx_v_b;
8523   char *__pyx_v_cpy;
8524   size_t __pyx_v_nbytes;
8525   PyObject *__pyx_v_line = NULL;
8526   PyObject *__pyx_v_s = NULL;
8527   PyObject *__pyx_r = NULL;
8528   __Pyx_RefNannyDeclarations
8529   PyObject *__pyx_t_1 = NULL;
8530   PyObject *__pyx_t_2 = NULL;
8531   int __pyx_t_3;
8532   int __pyx_t_4;
8533   char *__pyx_t_5;
8534   Py_ssize_t __pyx_t_6;
8535   int __pyx_t_7;
8536   int __pyx_t_8;
8537   PyObject *__pyx_t_9 = NULL;
8538   PyObject *__pyx_t_10 = NULL;
8539   int __pyx_lineno = 0;
8540   const char *__pyx_filename = NULL;
8541   int __pyx_clineno = 0;
8542   __Pyx_RefNannySetupContext("__next__", 0);
8543
8544   /* "ctabix.pyx":847
8545  *         cdef char * b, * cpy
8546  *         cdef size_t nbytes
8547  *         while 1:             # <<<<<<<<<<<<<<
8548  * 
8549  *             line = self.infile.readline()
8550  */
8551   while (1) {
8552     if (!1) break;
8553
8554     /* "ctabix.pyx":849
8555  *         while 1:
8556  * 
8557  *             line = self.infile.readline()             # <<<<<<<<<<<<<<
8558  *             if not line: break
8559  * 
8560  */
8561     __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__infile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8562     __Pyx_GOTREF(__pyx_t_1);
8563     __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__readline); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8564     __Pyx_GOTREF(__pyx_t_2);
8565     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8566     __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8567     __Pyx_GOTREF(__pyx_t_1);
8568     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8569     __Pyx_XDECREF(__pyx_v_line);
8570     __pyx_v_line = __pyx_t_1;
8571     __pyx_t_1 = 0;
8572
8573     /* "ctabix.pyx":850
8574  * 
8575  *             line = self.infile.readline()
8576  *             if not line: break             # <<<<<<<<<<<<<<
8577  * 
8578  *             s = _force_bytes( line )
8579  */
8580     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_line); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8581     __pyx_t_4 = (!__pyx_t_3);
8582     if (__pyx_t_4) {
8583       goto __pyx_L4_break;
8584       goto __pyx_L5;
8585     }
8586     __pyx_L5:;
8587
8588     /* "ctabix.pyx":852
8589  *             if not line: break
8590  * 
8591  *             s = _force_bytes( line )             # <<<<<<<<<<<<<<
8592  *             b = s
8593  *             nbytes = len( line )
8594  */
8595     __pyx_t_1 = ((PyObject *)__pyx_f_6ctabix__force_bytes(__pyx_v_line)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8596     __Pyx_GOTREF(__pyx_t_1);
8597     __Pyx_XDECREF(((PyObject *)__pyx_v_s));
8598     __pyx_v_s = ((PyObject*)__pyx_t_1);
8599     __pyx_t_1 = 0;
8600
8601     /* "ctabix.pyx":853
8602  * 
8603  *             s = _force_bytes( line )
8604  *             b = s             # <<<<<<<<<<<<<<
8605  *             nbytes = len( line )
8606  *             assert b[nbytes] == '\0'
8607  */
8608     __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_s)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8609     __pyx_v_b = __pyx_t_5;
8610
8611     /* "ctabix.pyx":854
8612  *             s = _force_bytes( line )
8613  *             b = s
8614  *             nbytes = len( line )             # <<<<<<<<<<<<<<
8615  *             assert b[nbytes] == '\0'
8616  * 
8617  */
8618     __pyx_t_6 = PyObject_Length(__pyx_v_line); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8619     __pyx_v_nbytes = __pyx_t_6;
8620
8621     /* "ctabix.pyx":855
8622  *             b = s
8623  *             nbytes = len( line )
8624  *             assert b[nbytes] == '\0'             # <<<<<<<<<<<<<<
8625  * 
8626  *             # skip comments
8627  */
8628     #ifndef CYTHON_WITHOUT_ASSERTIONS
8629     if (unlikely(!((__pyx_v_b[__pyx_v_nbytes]) == '\x00'))) {
8630       PyErr_SetNone(PyExc_AssertionError);
8631       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8632     }
8633     #endif
8634
8635     /* "ctabix.pyx":858
8636  * 
8637  *             # skip comments
8638  *             if (b[0] == '#'): continue             # <<<<<<<<<<<<<<
8639  * 
8640  *             # skip empty lines
8641  */
8642     __pyx_t_4 = ((__pyx_v_b[0]) == '#');
8643     if (__pyx_t_4) {
8644       goto __pyx_L3_continue;
8645       goto __pyx_L6;
8646     }
8647     __pyx_L6:;
8648
8649     /* "ctabix.pyx":861
8650  * 
8651  *             # skip empty lines
8652  *             if b[0] == '\0' or b[0] == '\n' or b[0] == '\r': continue             # <<<<<<<<<<<<<<
8653  * 
8654  *             # make sure that entry is complete
8655  */
8656     __pyx_t_4 = ((__pyx_v_b[0]) == '\x00');
8657     if (!__pyx_t_4) {
8658       __pyx_t_3 = ((__pyx_v_b[0]) == '\n');
8659       if (!__pyx_t_3) {
8660         __pyx_t_7 = ((__pyx_v_b[0]) == '\r');
8661         __pyx_t_8 = __pyx_t_7;
8662       } else {
8663         __pyx_t_8 = __pyx_t_3;
8664       }
8665       __pyx_t_3 = __pyx_t_8;
8666     } else {
8667       __pyx_t_3 = __pyx_t_4;
8668     }
8669     if (__pyx_t_3) {
8670       goto __pyx_L3_continue;
8671       goto __pyx_L7;
8672     }
8673     __pyx_L7:;
8674
8675     /* "ctabix.pyx":864
8676  * 
8677  *             # make sure that entry is complete
8678  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':             # <<<<<<<<<<<<<<
8679  *                 raise ValueError( "incomplete line at %s" % line )
8680  * 
8681  */
8682     __pyx_t_3 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\n');
8683     if (__pyx_t_3) {
8684       __pyx_t_4 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\r');
8685       __pyx_t_8 = __pyx_t_4;
8686     } else {
8687       __pyx_t_8 = __pyx_t_3;
8688     }
8689     if (__pyx_t_8) {
8690
8691       /* "ctabix.pyx":865
8692  *             # make sure that entry is complete
8693  *             if b[nbytes-1] != '\n' and b[nbytes-1] != '\r':
8694  *                 raise ValueError( "incomplete line at %s" % line )             # <<<<<<<<<<<<<<
8695  * 
8696  *             # create a copy
8697  */
8698       __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), __pyx_v_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8699       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
8700       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8701       __Pyx_GOTREF(__pyx_t_2);
8702       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
8703       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
8704       __pyx_t_1 = 0;
8705       __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8706       __Pyx_GOTREF(__pyx_t_1);
8707       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
8708       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
8709       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8710       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8711       goto __pyx_L8;
8712     }
8713     __pyx_L8:;
8714
8715     /* "ctabix.pyx":868
8716  * 
8717  *             # create a copy
8718  *             cpy = <char*>malloc(nbytes+1)             # <<<<<<<<<<<<<<
8719  *             if cpy == NULL: raise MemoryError()
8720  *             memcpy( cpy, b, nbytes+1)
8721  */
8722     __pyx_v_cpy = ((char *)malloc((__pyx_v_nbytes + 1)));
8723
8724     /* "ctabix.pyx":869
8725  *             # create a copy
8726  *             cpy = <char*>malloc(nbytes+1)
8727  *             if cpy == NULL: raise MemoryError()             # <<<<<<<<<<<<<<
8728  *             memcpy( cpy, b, nbytes+1)
8729  * 
8730  */
8731     __pyx_t_8 = (__pyx_v_cpy == NULL);
8732     if (__pyx_t_8) {
8733       PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8734       goto __pyx_L9;
8735     }
8736     __pyx_L9:;
8737
8738     /* "ctabix.pyx":870
8739  *             cpy = <char*>malloc(nbytes+1)
8740  *             if cpy == NULL: raise MemoryError()
8741  *             memcpy( cpy, b, nbytes+1)             # <<<<<<<<<<<<<<
8742  * 
8743  *             return self.parser(cpy, nbytes)
8744  */
8745     memcpy(__pyx_v_cpy, __pyx_v_b, (__pyx_v_nbytes + 1));
8746
8747     /* "ctabix.pyx":872
8748  *             memcpy( cpy, b, nbytes+1)
8749  * 
8750  *             return self.parser(cpy, nbytes)             # <<<<<<<<<<<<<<
8751  * 
8752  *         raise StopIteration
8753  */
8754     __Pyx_XDECREF(__pyx_r);
8755     __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__parser); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8756     __Pyx_GOTREF(__pyx_t_1);
8757     __pyx_t_2 = PyBytes_FromString(__pyx_v_cpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8758     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
8759     __pyx_t_9 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8760     __Pyx_GOTREF(__pyx_t_9);
8761     __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8762     __Pyx_GOTREF(__pyx_t_10);
8763     PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_2));
8764     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
8765     PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
8766     __Pyx_GIVEREF(__pyx_t_9);
8767     __pyx_t_2 = 0;
8768     __pyx_t_9 = 0;
8769     __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8770     __Pyx_GOTREF(__pyx_t_9);
8771     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8772     __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
8773     __pyx_r = __pyx_t_9;
8774     __pyx_t_9 = 0;
8775     goto __pyx_L0;
8776     __pyx_L3_continue:;
8777   }
8778   __pyx_L4_break:;
8779
8780   /* "ctabix.pyx":874
8781  *             return self.parser(cpy, nbytes)
8782  * 
8783  *         raise StopIteration             # <<<<<<<<<<<<<<
8784  * 
8785  *     # python version - required for python 2.7
8786  */
8787   __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
8788   {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8789
8790   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8791   goto __pyx_L0;
8792   __pyx_L1_error:;
8793   __Pyx_XDECREF(__pyx_t_1);
8794   __Pyx_XDECREF(__pyx_t_2);
8795   __Pyx_XDECREF(__pyx_t_9);
8796   __Pyx_XDECREF(__pyx_t_10);
8797   __Pyx_AddTraceback("ctabix.tabix_generic_iterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8798   __pyx_r = NULL;
8799   __pyx_L0:;
8800   __Pyx_XDECREF(__pyx_v_line);
8801   __Pyx_XDECREF(__pyx_v_s);
8802   __Pyx_XGIVEREF(__pyx_r);
8803   __Pyx_RefNannyFinishContext();
8804   return __pyx_r;
8805 }
8806
8807 /* Python wrapper */
8808 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_7next(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
8809 static char __pyx_doc_6ctabix_22tabix_generic_iterator_6next[] = "tabix_generic_iterator.next(self)";
8810 static PyMethodDef __pyx_mdef_6ctabix_22tabix_generic_iterator_7next = {__Pyx_NAMESTR("next"), (PyCFunction)__pyx_pw_6ctabix_22tabix_generic_iterator_7next, METH_O, __Pyx_DOCSTR(__pyx_doc_6ctabix_22tabix_generic_iterator_6next)};
8811 static PyObject *__pyx_pw_6ctabix_22tabix_generic_iterator_7next(PyObject *__pyx_self, PyObject *__pyx_v_self) {
8812   PyObject *__pyx_r = 0;
8813   __Pyx_RefNannyDeclarations
8814   __Pyx_RefNannySetupContext("next (wrapper)", 0);
8815   __pyx_r = __pyx_pf_6ctabix_22tabix_generic_iterator_6next(__pyx_self, ((PyObject *)__pyx_v_self));
8816   __Pyx_RefNannyFinishContext();
8817   return __pyx_r;
8818 }
8819
8820 /* "ctabix.pyx":877
8821  * 
8822  *     # python version - required for python 2.7
8823  *     def next(self):             # <<<<<<<<<<<<<<
8824  *         return self.__next__()
8825  * 
8826  */
8827
8828 static PyObject *__pyx_pf_6ctabix_22tabix_generic_iterator_6next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
8829   PyObject *__pyx_r = NULL;
8830   __Pyx_RefNannyDeclarations
8831   PyObject *__pyx_t_1 = NULL;
8832   PyObject *__pyx_t_2 = NULL;
8833   int __pyx_lineno = 0;
8834   const char *__pyx_filename = NULL;
8835   int __pyx_clineno = 0;
8836   __Pyx_RefNannySetupContext("next", 0);
8837
8838   /* "ctabix.pyx":878
8839  *     # python version - required for python 2.7
8840  *     def next(self):
8841  *         return self.__next__()             # <<<<<<<<<<<<<<
8842  * 
8843  * def tabix_iterator( infile, parser ):
8844  */
8845   __Pyx_XDECREF(__pyx_r);
8846   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8847   __Pyx_GOTREF(__pyx_t_1);
8848   __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 = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8849   __Pyx_GOTREF(__pyx_t_2);
8850   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8851   __pyx_r = __pyx_t_2;
8852   __pyx_t_2 = 0;
8853   goto __pyx_L0;
8854
8855   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8856   goto __pyx_L0;
8857   __pyx_L1_error:;
8858   __Pyx_XDECREF(__pyx_t_1);
8859   __Pyx_XDECREF(__pyx_t_2);
8860   __Pyx_AddTraceback("ctabix.tabix_generic_iterator.next", __pyx_clineno, __pyx_lineno, __pyx_filename);
8861   __pyx_r = NULL;
8862   __pyx_L0:;
8863   __Pyx_XGIVEREF(__pyx_r);
8864   __Pyx_RefNannyFinishContext();
8865   return __pyx_r;
8866 }
8867
8868 /* Python wrapper */
8869 static PyObject *__pyx_pw_6ctabix_5tabix_iterator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8870 static char __pyx_doc_6ctabix_4tabix_iterator[] = "tabix_iterator(infile, parser)\nreturn an iterator over all entries in a file.";
8871 static PyMethodDef __pyx_mdef_6ctabix_5tabix_iterator = {__Pyx_NAMESTR("tabix_iterator"), (PyCFunction)__pyx_pw_6ctabix_5tabix_iterator, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_4tabix_iterator)};
8872 static PyObject *__pyx_pw_6ctabix_5tabix_iterator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8873   PyObject *__pyx_v_infile = 0;
8874   PyObject *__pyx_v_parser = 0;
8875   PyObject *__pyx_r = 0;
8876   __Pyx_RefNannyDeclarations
8877   __Pyx_RefNannySetupContext("tabix_iterator (wrapper)", 0);
8878   {
8879     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__infile,&__pyx_n_s__parser,0};
8880     PyObject* values[2] = {0,0};
8881     if (unlikely(__pyx_kwds)) {
8882       Py_ssize_t kw_args;
8883       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8884       switch (pos_args) {
8885         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8886         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8887         case  0: break;
8888         default: goto __pyx_L5_argtuple_error;
8889       }
8890       kw_args = PyDict_Size(__pyx_kwds);
8891       switch (pos_args) {
8892         case  0:
8893         if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile)) != 0)) kw_args--;
8894         else goto __pyx_L5_argtuple_error;
8895         case  1:
8896         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser)) != 0)) kw_args--;
8897         else {
8898           __Pyx_RaiseArgtupleInvalid("tabix_iterator", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8899         }
8900       }
8901       if (unlikely(kw_args > 0)) {
8902         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tabix_iterator") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8903       }
8904     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
8905       goto __pyx_L5_argtuple_error;
8906     } else {
8907       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8908       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8909     }
8910     __pyx_v_infile = values[0];
8911     __pyx_v_parser = values[1];
8912   }
8913   goto __pyx_L4_argument_unpacking_done;
8914   __pyx_L5_argtuple_error:;
8915   __Pyx_RaiseArgtupleInvalid("tabix_iterator", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
8916   __pyx_L3_error:;
8917   __Pyx_AddTraceback("ctabix.tabix_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
8918   __Pyx_RefNannyFinishContext();
8919   return NULL;
8920   __pyx_L4_argument_unpacking_done:;
8921   __pyx_r = __pyx_pf_6ctabix_4tabix_iterator(__pyx_self, __pyx_v_infile, __pyx_v_parser);
8922   __Pyx_RefNannyFinishContext();
8923   return __pyx_r;
8924 }
8925
8926 /* "ctabix.pyx":880
8927  *         return self.__next__()
8928  * 
8929  * def tabix_iterator( infile, parser ):             # <<<<<<<<<<<<<<
8930  *     """return an iterator over all entries in a file."""
8931  *     return tabix_generic_iterator( infile, parser )
8932  */
8933
8934 static PyObject *__pyx_pf_6ctabix_4tabix_iterator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_infile, PyObject *__pyx_v_parser) {
8935   PyObject *__pyx_r = NULL;
8936   __Pyx_RefNannyDeclarations
8937   PyObject *__pyx_t_1 = NULL;
8938   PyObject *__pyx_t_2 = NULL;
8939   PyObject *__pyx_t_3 = NULL;
8940   int __pyx_lineno = 0;
8941   const char *__pyx_filename = NULL;
8942   int __pyx_clineno = 0;
8943   __Pyx_RefNannySetupContext("tabix_iterator", 0);
8944
8945   /* "ctabix.pyx":882
8946  * def tabix_iterator( infile, parser ):
8947  *     """return an iterator over all entries in a file."""
8948  *     return tabix_generic_iterator( infile, parser )             # <<<<<<<<<<<<<<
8949  *     # file objects can use C stdio
8950  *     # used to be: isinstance( infile, file):
8951  */
8952   __Pyx_XDECREF(__pyx_r);
8953   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8954   __Pyx_GOTREF(__pyx_t_1);
8955   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8956   __Pyx_GOTREF(__pyx_t_2);
8957   __Pyx_INCREF(__pyx_v_infile);
8958   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_infile);
8959   __Pyx_GIVEREF(__pyx_v_infile);
8960   __Pyx_INCREF(__pyx_v_parser);
8961   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_parser);
8962   __Pyx_GIVEREF(__pyx_v_parser);
8963   __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 = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8964   __Pyx_GOTREF(__pyx_t_3);
8965   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8966   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
8967   __pyx_r = __pyx_t_3;
8968   __pyx_t_3 = 0;
8969   goto __pyx_L0;
8970
8971   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8972   goto __pyx_L0;
8973   __pyx_L1_error:;
8974   __Pyx_XDECREF(__pyx_t_1);
8975   __Pyx_XDECREF(__pyx_t_2);
8976   __Pyx_XDECREF(__pyx_t_3);
8977   __Pyx_AddTraceback("ctabix.tabix_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
8978   __pyx_r = NULL;
8979   __pyx_L0:;
8980   __Pyx_XGIVEREF(__pyx_r);
8981   __Pyx_RefNannyFinishContext();
8982   return __pyx_r;
8983 }
8984
8985 static PyObject *__pyx_tp_new_6ctabix_Tabixfile(PyTypeObject *t, PyObject *a, PyObject *k) {
8986   PyObject *o = (*t->tp_alloc)(t, 0);
8987   if (!o) return 0;
8988   if (__pyx_pw_6ctabix_9Tabixfile_1__cinit__(o, a, k) < 0) {
8989     Py_DECREF(o); o = 0;
8990   }
8991   return o;
8992 }
8993
8994 static void __pyx_tp_dealloc_6ctabix_Tabixfile(PyObject *o) {
8995   {
8996     PyObject *etype, *eval, *etb;
8997     PyErr_Fetch(&etype, &eval, &etb);
8998     ++Py_REFCNT(o);
8999     __pyx_pw_6ctabix_9Tabixfile_13__dealloc__(o);
9000     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
9001     --Py_REFCNT(o);
9002     PyErr_Restore(etype, eval, etb);
9003   }
9004   (*Py_TYPE(o)->tp_free)(o);
9005 }
9006
9007 static PyObject *__pyx_getprop_6ctabix_9Tabixfile_filename(PyObject *o, CYTHON_UNUSED void *x) {
9008   return __pyx_pw_6ctabix_9Tabixfile_8filename_1__get__(o);
9009 }
9010
9011 static PyObject *__pyx_getprop_6ctabix_9Tabixfile_header(PyObject *o, CYTHON_UNUSED void *x) {
9012   return __pyx_pw_6ctabix_9Tabixfile_6header_1__get__(o);
9013 }
9014
9015 static PyObject *__pyx_getprop_6ctabix_9Tabixfile_contigs(PyObject *o, CYTHON_UNUSED void *x) {
9016   return __pyx_pw_6ctabix_9Tabixfile_7contigs_1__get__(o);
9017 }
9018
9019 static PyMethodDef __pyx_methods_6ctabix_Tabixfile[] = {
9020   {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pw_6ctabix_9Tabixfile_3_isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_2_isOpen)},
9021   {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pw_6ctabix_9Tabixfile_5_open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_4_open)},
9022   {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pw_6ctabix_9Tabixfile_7_parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_6_parseRegion)},
9023   {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pw_6ctabix_9Tabixfile_9fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_8fetch)},
9024   {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pw_6ctabix_9Tabixfile_11close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_10close)},
9025   {0, 0, 0, 0}
9026 };
9027
9028 static struct PyGetSetDef __pyx_getsets_6ctabix_Tabixfile[] = {
9029   {(char *)"filename", __pyx_getprop_6ctabix_9Tabixfile_filename, 0, __Pyx_DOCSTR(__pyx_k_57), 0},
9030   {(char *)"header", __pyx_getprop_6ctabix_9Tabixfile_header, 0, __Pyx_DOCSTR(__pyx_k_58), 0},
9031   {(char *)"contigs", __pyx_getprop_6ctabix_9Tabixfile_contigs, 0, __Pyx_DOCSTR(__pyx_k_59), 0},
9032   {0, 0, 0, 0, 0}
9033 };
9034
9035 static PyNumberMethods __pyx_tp_as_number_Tabixfile = {
9036   0, /*nb_add*/
9037   0, /*nb_subtract*/
9038   0, /*nb_multiply*/
9039   #if PY_MAJOR_VERSION < 3
9040   0, /*nb_divide*/
9041   #endif
9042   0, /*nb_remainder*/
9043   0, /*nb_divmod*/
9044   0, /*nb_power*/
9045   0, /*nb_negative*/
9046   0, /*nb_positive*/
9047   0, /*nb_absolute*/
9048   0, /*nb_nonzero*/
9049   0, /*nb_invert*/
9050   0, /*nb_lshift*/
9051   0, /*nb_rshift*/
9052   0, /*nb_and*/
9053   0, /*nb_xor*/
9054   0, /*nb_or*/
9055   #if PY_MAJOR_VERSION < 3
9056   0, /*nb_coerce*/
9057   #endif
9058   0, /*nb_int*/
9059   #if PY_MAJOR_VERSION < 3
9060   0, /*nb_long*/
9061   #else
9062   0, /*reserved*/
9063   #endif
9064   0, /*nb_float*/
9065   #if PY_MAJOR_VERSION < 3
9066   0, /*nb_oct*/
9067   #endif
9068   #if PY_MAJOR_VERSION < 3
9069   0, /*nb_hex*/
9070   #endif
9071   0, /*nb_inplace_add*/
9072   0, /*nb_inplace_subtract*/
9073   0, /*nb_inplace_multiply*/
9074   #if PY_MAJOR_VERSION < 3
9075   0, /*nb_inplace_divide*/
9076   #endif
9077   0, /*nb_inplace_remainder*/
9078   0, /*nb_inplace_power*/
9079   0, /*nb_inplace_lshift*/
9080   0, /*nb_inplace_rshift*/
9081   0, /*nb_inplace_and*/
9082   0, /*nb_inplace_xor*/
9083   0, /*nb_inplace_or*/
9084   0, /*nb_floor_divide*/
9085   0, /*nb_true_divide*/
9086   0, /*nb_inplace_floor_divide*/
9087   0, /*nb_inplace_true_divide*/
9088   #if PY_VERSION_HEX >= 0x02050000
9089   0, /*nb_index*/
9090   #endif
9091 };
9092
9093 static PySequenceMethods __pyx_tp_as_sequence_Tabixfile = {
9094   0, /*sq_length*/
9095   0, /*sq_concat*/
9096   0, /*sq_repeat*/
9097   0, /*sq_item*/
9098   0, /*sq_slice*/
9099   0, /*sq_ass_item*/
9100   0, /*sq_ass_slice*/
9101   0, /*sq_contains*/
9102   0, /*sq_inplace_concat*/
9103   0, /*sq_inplace_repeat*/
9104 };
9105
9106 static PyMappingMethods __pyx_tp_as_mapping_Tabixfile = {
9107   0, /*mp_length*/
9108   0, /*mp_subscript*/
9109   0, /*mp_ass_subscript*/
9110 };
9111
9112 static PyBufferProcs __pyx_tp_as_buffer_Tabixfile = {
9113   #if PY_MAJOR_VERSION < 3
9114   0, /*bf_getreadbuffer*/
9115   #endif
9116   #if PY_MAJOR_VERSION < 3
9117   0, /*bf_getwritebuffer*/
9118   #endif
9119   #if PY_MAJOR_VERSION < 3
9120   0, /*bf_getsegcount*/
9121   #endif
9122   #if PY_MAJOR_VERSION < 3
9123   0, /*bf_getcharbuffer*/
9124   #endif
9125   #if PY_VERSION_HEX >= 0x02060000
9126   0, /*bf_getbuffer*/
9127   #endif
9128   #if PY_VERSION_HEX >= 0x02060000
9129   0, /*bf_releasebuffer*/
9130   #endif
9131 };
9132
9133 static PyTypeObject __pyx_type_6ctabix_Tabixfile = {
9134   PyVarObject_HEAD_INIT(0, 0)
9135   __Pyx_NAMESTR("ctabix.Tabixfile"), /*tp_name*/
9136   sizeof(struct __pyx_obj_6ctabix_Tabixfile), /*tp_basicsize*/
9137   0, /*tp_itemsize*/
9138   __pyx_tp_dealloc_6ctabix_Tabixfile, /*tp_dealloc*/
9139   0, /*tp_print*/
9140   0, /*tp_getattr*/
9141   0, /*tp_setattr*/
9142   #if PY_MAJOR_VERSION < 3
9143   0, /*tp_compare*/
9144   #else
9145   0, /*reserved*/
9146   #endif
9147   0, /*tp_repr*/
9148   &__pyx_tp_as_number_Tabixfile, /*tp_as_number*/
9149   &__pyx_tp_as_sequence_Tabixfile, /*tp_as_sequence*/
9150   &__pyx_tp_as_mapping_Tabixfile, /*tp_as_mapping*/
9151   0, /*tp_hash*/
9152   0, /*tp_call*/
9153   0, /*tp_str*/
9154   0, /*tp_getattro*/
9155   0, /*tp_setattro*/
9156   &__pyx_tp_as_buffer_Tabixfile, /*tp_as_buffer*/
9157   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
9158   __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*/
9159   0, /*tp_traverse*/
9160   0, /*tp_clear*/
9161   0, /*tp_richcompare*/
9162   0, /*tp_weaklistoffset*/
9163   0, /*tp_iter*/
9164   0, /*tp_iternext*/
9165   __pyx_methods_6ctabix_Tabixfile, /*tp_methods*/
9166   0, /*tp_members*/
9167   __pyx_getsets_6ctabix_Tabixfile, /*tp_getset*/
9168   0, /*tp_base*/
9169   0, /*tp_dict*/
9170   0, /*tp_descr_get*/
9171   0, /*tp_descr_set*/
9172   0, /*tp_dictoffset*/
9173   0, /*tp_init*/
9174   0, /*tp_alloc*/
9175   __pyx_tp_new_6ctabix_Tabixfile, /*tp_new*/
9176   0, /*tp_free*/
9177   0, /*tp_is_gc*/
9178   0, /*tp_bases*/
9179   0, /*tp_mro*/
9180   0, /*tp_cache*/
9181   0, /*tp_subclasses*/
9182   0, /*tp_weaklist*/
9183   0, /*tp_del*/
9184   #if PY_VERSION_HEX >= 0x02060000
9185   0, /*tp_version_tag*/
9186   #endif
9187 };
9188
9189 static PyObject *__pyx_tp_new_6ctabix_TabixIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
9190   PyObject *o = (*t->tp_alloc)(t, 0);
9191   if (!o) return 0;
9192   if (__pyx_pw_6ctabix_13TabixIterator_1__cinit__(o, a, k) < 0) {
9193     Py_DECREF(o); o = 0;
9194   }
9195   return o;
9196 }
9197
9198 static void __pyx_tp_dealloc_6ctabix_TabixIterator(PyObject *o) {
9199   {
9200     PyObject *etype, *eval, *etb;
9201     PyErr_Fetch(&etype, &eval, &etb);
9202     ++Py_REFCNT(o);
9203     __pyx_pw_6ctabix_13TabixIterator_7__dealloc__(o);
9204     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
9205     --Py_REFCNT(o);
9206     PyErr_Restore(etype, eval, etb);
9207   }
9208   (*Py_TYPE(o)->tp_free)(o);
9209 }
9210
9211 static PyMethodDef __pyx_methods_6ctabix_TabixIterator[] = {
9212   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6ctabix_13TabixIterator_5__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_13TabixIterator_4__next__)},
9213   {0, 0, 0, 0}
9214 };
9215
9216 static PyNumberMethods __pyx_tp_as_number_TabixIterator = {
9217   0, /*nb_add*/
9218   0, /*nb_subtract*/
9219   0, /*nb_multiply*/
9220   #if PY_MAJOR_VERSION < 3
9221   0, /*nb_divide*/
9222   #endif
9223   0, /*nb_remainder*/
9224   0, /*nb_divmod*/
9225   0, /*nb_power*/
9226   0, /*nb_negative*/
9227   0, /*nb_positive*/
9228   0, /*nb_absolute*/
9229   0, /*nb_nonzero*/
9230   0, /*nb_invert*/
9231   0, /*nb_lshift*/
9232   0, /*nb_rshift*/
9233   0, /*nb_and*/
9234   0, /*nb_xor*/
9235   0, /*nb_or*/
9236   #if PY_MAJOR_VERSION < 3
9237   0, /*nb_coerce*/
9238   #endif
9239   0, /*nb_int*/
9240   #if PY_MAJOR_VERSION < 3
9241   0, /*nb_long*/
9242   #else
9243   0, /*reserved*/
9244   #endif
9245   0, /*nb_float*/
9246   #if PY_MAJOR_VERSION < 3
9247   0, /*nb_oct*/
9248   #endif
9249   #if PY_MAJOR_VERSION < 3
9250   0, /*nb_hex*/
9251   #endif
9252   0, /*nb_inplace_add*/
9253   0, /*nb_inplace_subtract*/
9254   0, /*nb_inplace_multiply*/
9255   #if PY_MAJOR_VERSION < 3
9256   0, /*nb_inplace_divide*/
9257   #endif
9258   0, /*nb_inplace_remainder*/
9259   0, /*nb_inplace_power*/
9260   0, /*nb_inplace_lshift*/
9261   0, /*nb_inplace_rshift*/
9262   0, /*nb_inplace_and*/
9263   0, /*nb_inplace_xor*/
9264   0, /*nb_inplace_or*/
9265   0, /*nb_floor_divide*/
9266   0, /*nb_true_divide*/
9267   0, /*nb_inplace_floor_divide*/
9268   0, /*nb_inplace_true_divide*/
9269   #if PY_VERSION_HEX >= 0x02050000
9270   0, /*nb_index*/
9271   #endif
9272 };
9273
9274 static PySequenceMethods __pyx_tp_as_sequence_TabixIterator = {
9275   0, /*sq_length*/
9276   0, /*sq_concat*/
9277   0, /*sq_repeat*/
9278   0, /*sq_item*/
9279   0, /*sq_slice*/
9280   0, /*sq_ass_item*/
9281   0, /*sq_ass_slice*/
9282   0, /*sq_contains*/
9283   0, /*sq_inplace_concat*/
9284   0, /*sq_inplace_repeat*/
9285 };
9286
9287 static PyMappingMethods __pyx_tp_as_mapping_TabixIterator = {
9288   0, /*mp_length*/
9289   0, /*mp_subscript*/
9290   0, /*mp_ass_subscript*/
9291 };
9292
9293 static PyBufferProcs __pyx_tp_as_buffer_TabixIterator = {
9294   #if PY_MAJOR_VERSION < 3
9295   0, /*bf_getreadbuffer*/
9296   #endif
9297   #if PY_MAJOR_VERSION < 3
9298   0, /*bf_getwritebuffer*/
9299   #endif
9300   #if PY_MAJOR_VERSION < 3
9301   0, /*bf_getsegcount*/
9302   #endif
9303   #if PY_MAJOR_VERSION < 3
9304   0, /*bf_getcharbuffer*/
9305   #endif
9306   #if PY_VERSION_HEX >= 0x02060000
9307   0, /*bf_getbuffer*/
9308   #endif
9309   #if PY_VERSION_HEX >= 0x02060000
9310   0, /*bf_releasebuffer*/
9311   #endif
9312 };
9313
9314 static PyTypeObject __pyx_type_6ctabix_TabixIterator = {
9315   PyVarObject_HEAD_INIT(0, 0)
9316   __Pyx_NAMESTR("ctabix.TabixIterator"), /*tp_name*/
9317   sizeof(struct __pyx_obj_6ctabix_TabixIterator), /*tp_basicsize*/
9318   0, /*tp_itemsize*/
9319   __pyx_tp_dealloc_6ctabix_TabixIterator, /*tp_dealloc*/
9320   0, /*tp_print*/
9321   0, /*tp_getattr*/
9322   0, /*tp_setattr*/
9323   #if PY_MAJOR_VERSION < 3
9324   0, /*tp_compare*/
9325   #else
9326   0, /*reserved*/
9327   #endif
9328   0, /*tp_repr*/
9329   &__pyx_tp_as_number_TabixIterator, /*tp_as_number*/
9330   &__pyx_tp_as_sequence_TabixIterator, /*tp_as_sequence*/
9331   &__pyx_tp_as_mapping_TabixIterator, /*tp_as_mapping*/
9332   0, /*tp_hash*/
9333   0, /*tp_call*/
9334   0, /*tp_str*/
9335   0, /*tp_getattro*/
9336   0, /*tp_setattro*/
9337   &__pyx_tp_as_buffer_TabixIterator, /*tp_as_buffer*/
9338   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
9339   __Pyx_DOCSTR("iterates over rows in *tabixfile* in region\n    given by *tid*, *start* and *end*.\n    "), /*tp_doc*/
9340   0, /*tp_traverse*/
9341   0, /*tp_clear*/
9342   0, /*tp_richcompare*/
9343   0, /*tp_weaklistoffset*/
9344   __pyx_pw_6ctabix_13TabixIterator_3__iter__, /*tp_iter*/
9345   __pyx_pw_6ctabix_13TabixIterator_5__next__, /*tp_iternext*/
9346   __pyx_methods_6ctabix_TabixIterator, /*tp_methods*/
9347   0, /*tp_members*/
9348   0, /*tp_getset*/
9349   0, /*tp_base*/
9350   0, /*tp_dict*/
9351   0, /*tp_descr_get*/
9352   0, /*tp_descr_set*/
9353   0, /*tp_dictoffset*/
9354   0, /*tp_init*/
9355   0, /*tp_alloc*/
9356   __pyx_tp_new_6ctabix_TabixIterator, /*tp_new*/
9357   0, /*tp_free*/
9358   0, /*tp_is_gc*/
9359   0, /*tp_bases*/
9360   0, /*tp_mro*/
9361   0, /*tp_cache*/
9362   0, /*tp_subclasses*/
9363   0, /*tp_weaklist*/
9364   0, /*tp_del*/
9365   #if PY_VERSION_HEX >= 0x02060000
9366   0, /*tp_version_tag*/
9367   #endif
9368 };
9369
9370 static PyObject *__pyx_tp_new_6ctabix_TabixHeaderIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
9371   PyObject *o = (*t->tp_alloc)(t, 0);
9372   if (!o) return 0;
9373   if (__pyx_pw_6ctabix_19TabixHeaderIterator_1__cinit__(o, a, k) < 0) {
9374     Py_DECREF(o); o = 0;
9375   }
9376   return o;
9377 }
9378
9379 static void __pyx_tp_dealloc_6ctabix_TabixHeaderIterator(PyObject *o) {
9380   {
9381     PyObject *etype, *eval, *etb;
9382     PyErr_Fetch(&etype, &eval, &etb);
9383     ++Py_REFCNT(o);
9384     __pyx_pw_6ctabix_19TabixHeaderIterator_7__dealloc__(o);
9385     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
9386     --Py_REFCNT(o);
9387     PyErr_Restore(etype, eval, etb);
9388   }
9389   (*Py_TYPE(o)->tp_free)(o);
9390 }
9391
9392 static PyMethodDef __pyx_methods_6ctabix_TabixHeaderIterator[] = {
9393   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6ctabix_19TabixHeaderIterator_5__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_19TabixHeaderIterator_4__next__)},
9394   {0, 0, 0, 0}
9395 };
9396
9397 static PyNumberMethods __pyx_tp_as_number_TabixHeaderIterator = {
9398   0, /*nb_add*/
9399   0, /*nb_subtract*/
9400   0, /*nb_multiply*/
9401   #if PY_MAJOR_VERSION < 3
9402   0, /*nb_divide*/
9403   #endif
9404   0, /*nb_remainder*/
9405   0, /*nb_divmod*/
9406   0, /*nb_power*/
9407   0, /*nb_negative*/
9408   0, /*nb_positive*/
9409   0, /*nb_absolute*/
9410   0, /*nb_nonzero*/
9411   0, /*nb_invert*/
9412   0, /*nb_lshift*/
9413   0, /*nb_rshift*/
9414   0, /*nb_and*/
9415   0, /*nb_xor*/
9416   0, /*nb_or*/
9417   #if PY_MAJOR_VERSION < 3
9418   0, /*nb_coerce*/
9419   #endif
9420   0, /*nb_int*/
9421   #if PY_MAJOR_VERSION < 3
9422   0, /*nb_long*/
9423   #else
9424   0, /*reserved*/
9425   #endif
9426   0, /*nb_float*/
9427   #if PY_MAJOR_VERSION < 3
9428   0, /*nb_oct*/
9429   #endif
9430   #if PY_MAJOR_VERSION < 3
9431   0, /*nb_hex*/
9432   #endif
9433   0, /*nb_inplace_add*/
9434   0, /*nb_inplace_subtract*/
9435   0, /*nb_inplace_multiply*/
9436   #if PY_MAJOR_VERSION < 3
9437   0, /*nb_inplace_divide*/
9438   #endif
9439   0, /*nb_inplace_remainder*/
9440   0, /*nb_inplace_power*/
9441   0, /*nb_inplace_lshift*/
9442   0, /*nb_inplace_rshift*/
9443   0, /*nb_inplace_and*/
9444   0, /*nb_inplace_xor*/
9445   0, /*nb_inplace_or*/
9446   0, /*nb_floor_divide*/
9447   0, /*nb_true_divide*/
9448   0, /*nb_inplace_floor_divide*/
9449   0, /*nb_inplace_true_divide*/
9450   #if PY_VERSION_HEX >= 0x02050000
9451   0, /*nb_index*/
9452   #endif
9453 };
9454
9455 static PySequenceMethods __pyx_tp_as_sequence_TabixHeaderIterator = {
9456   0, /*sq_length*/
9457   0, /*sq_concat*/
9458   0, /*sq_repeat*/
9459   0, /*sq_item*/
9460   0, /*sq_slice*/
9461   0, /*sq_ass_item*/
9462   0, /*sq_ass_slice*/
9463   0, /*sq_contains*/
9464   0, /*sq_inplace_concat*/
9465   0, /*sq_inplace_repeat*/
9466 };
9467
9468 static PyMappingMethods __pyx_tp_as_mapping_TabixHeaderIterator = {
9469   0, /*mp_length*/
9470   0, /*mp_subscript*/
9471   0, /*mp_ass_subscript*/
9472 };
9473
9474 static PyBufferProcs __pyx_tp_as_buffer_TabixHeaderIterator = {
9475   #if PY_MAJOR_VERSION < 3
9476   0, /*bf_getreadbuffer*/
9477   #endif
9478   #if PY_MAJOR_VERSION < 3
9479   0, /*bf_getwritebuffer*/
9480   #endif
9481   #if PY_MAJOR_VERSION < 3
9482   0, /*bf_getsegcount*/
9483   #endif
9484   #if PY_MAJOR_VERSION < 3
9485   0, /*bf_getcharbuffer*/
9486   #endif
9487   #if PY_VERSION_HEX >= 0x02060000
9488   0, /*bf_getbuffer*/
9489   #endif
9490   #if PY_VERSION_HEX >= 0x02060000
9491   0, /*bf_releasebuffer*/
9492   #endif
9493 };
9494
9495 static PyTypeObject __pyx_type_6ctabix_TabixHeaderIterator = {
9496   PyVarObject_HEAD_INIT(0, 0)
9497   __Pyx_NAMESTR("ctabix.TabixHeaderIterator"), /*tp_name*/
9498   sizeof(struct __pyx_obj_6ctabix_TabixHeaderIterator), /*tp_basicsize*/
9499   0, /*tp_itemsize*/
9500   __pyx_tp_dealloc_6ctabix_TabixHeaderIterator, /*tp_dealloc*/
9501   0, /*tp_print*/
9502   0, /*tp_getattr*/
9503   0, /*tp_setattr*/
9504   #if PY_MAJOR_VERSION < 3
9505   0, /*tp_compare*/
9506   #else
9507   0, /*reserved*/
9508   #endif
9509   0, /*tp_repr*/
9510   &__pyx_tp_as_number_TabixHeaderIterator, /*tp_as_number*/
9511   &__pyx_tp_as_sequence_TabixHeaderIterator, /*tp_as_sequence*/
9512   &__pyx_tp_as_mapping_TabixHeaderIterator, /*tp_as_mapping*/
9513   0, /*tp_hash*/
9514   0, /*tp_call*/
9515   0, /*tp_str*/
9516   0, /*tp_getattro*/
9517   0, /*tp_setattro*/
9518   &__pyx_tp_as_buffer_TabixHeaderIterator, /*tp_as_buffer*/
9519   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
9520   __Pyx_DOCSTR("return header lines.\n    "), /*tp_doc*/
9521   0, /*tp_traverse*/
9522   0, /*tp_clear*/
9523   0, /*tp_richcompare*/
9524   0, /*tp_weaklistoffset*/
9525   __pyx_pw_6ctabix_19TabixHeaderIterator_3__iter__, /*tp_iter*/
9526   __pyx_pw_6ctabix_19TabixHeaderIterator_5__next__, /*tp_iternext*/
9527   __pyx_methods_6ctabix_TabixHeaderIterator, /*tp_methods*/
9528   0, /*tp_members*/
9529   0, /*tp_getset*/
9530   0, /*tp_base*/
9531   0, /*tp_dict*/
9532   0, /*tp_descr_get*/
9533   0, /*tp_descr_set*/
9534   0, /*tp_dictoffset*/
9535   0, /*tp_init*/
9536   0, /*tp_alloc*/
9537   __pyx_tp_new_6ctabix_TabixHeaderIterator, /*tp_new*/
9538   0, /*tp_free*/
9539   0, /*tp_is_gc*/
9540   0, /*tp_bases*/
9541   0, /*tp_mro*/
9542   0, /*tp_cache*/
9543   0, /*tp_subclasses*/
9544   0, /*tp_weaklist*/
9545   0, /*tp_del*/
9546   #if PY_VERSION_HEX >= 0x02060000
9547   0, /*tp_version_tag*/
9548   #endif
9549 };
9550
9551 static PyObject *__pyx_tp_new_6ctabix_Parser(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
9552   PyObject *o = (*t->tp_alloc)(t, 0);
9553   if (!o) return 0;
9554   return o;
9555 }
9556
9557 static void __pyx_tp_dealloc_6ctabix_Parser(PyObject *o) {
9558   (*Py_TYPE(o)->tp_free)(o);
9559 }
9560
9561 static PyMethodDef __pyx_methods_6ctabix_Parser[] = {
9562   {0, 0, 0, 0}
9563 };
9564
9565 static PyNumberMethods __pyx_tp_as_number_Parser = {
9566   0, /*nb_add*/
9567   0, /*nb_subtract*/
9568   0, /*nb_multiply*/
9569   #if PY_MAJOR_VERSION < 3
9570   0, /*nb_divide*/
9571   #endif
9572   0, /*nb_remainder*/
9573   0, /*nb_divmod*/
9574   0, /*nb_power*/
9575   0, /*nb_negative*/
9576   0, /*nb_positive*/
9577   0, /*nb_absolute*/
9578   0, /*nb_nonzero*/
9579   0, /*nb_invert*/
9580   0, /*nb_lshift*/
9581   0, /*nb_rshift*/
9582   0, /*nb_and*/
9583   0, /*nb_xor*/
9584   0, /*nb_or*/
9585   #if PY_MAJOR_VERSION < 3
9586   0, /*nb_coerce*/
9587   #endif
9588   0, /*nb_int*/
9589   #if PY_MAJOR_VERSION < 3
9590   0, /*nb_long*/
9591   #else
9592   0, /*reserved*/
9593   #endif
9594   0, /*nb_float*/
9595   #if PY_MAJOR_VERSION < 3
9596   0, /*nb_oct*/
9597   #endif
9598   #if PY_MAJOR_VERSION < 3
9599   0, /*nb_hex*/
9600   #endif
9601   0, /*nb_inplace_add*/
9602   0, /*nb_inplace_subtract*/
9603   0, /*nb_inplace_multiply*/
9604   #if PY_MAJOR_VERSION < 3
9605   0, /*nb_inplace_divide*/
9606   #endif
9607   0, /*nb_inplace_remainder*/
9608   0, /*nb_inplace_power*/
9609   0, /*nb_inplace_lshift*/
9610   0, /*nb_inplace_rshift*/
9611   0, /*nb_inplace_and*/
9612   0, /*nb_inplace_xor*/
9613   0, /*nb_inplace_or*/
9614   0, /*nb_floor_divide*/
9615   0, /*nb_true_divide*/
9616   0, /*nb_inplace_floor_divide*/
9617   0, /*nb_inplace_true_divide*/
9618   #if PY_VERSION_HEX >= 0x02050000
9619   0, /*nb_index*/
9620   #endif
9621 };
9622
9623 static PySequenceMethods __pyx_tp_as_sequence_Parser = {
9624   0, /*sq_length*/
9625   0, /*sq_concat*/
9626   0, /*sq_repeat*/
9627   0, /*sq_item*/
9628   0, /*sq_slice*/
9629   0, /*sq_ass_item*/
9630   0, /*sq_ass_slice*/
9631   0, /*sq_contains*/
9632   0, /*sq_inplace_concat*/
9633   0, /*sq_inplace_repeat*/
9634 };
9635
9636 static PyMappingMethods __pyx_tp_as_mapping_Parser = {
9637   0, /*mp_length*/
9638   0, /*mp_subscript*/
9639   0, /*mp_ass_subscript*/
9640 };
9641
9642 static PyBufferProcs __pyx_tp_as_buffer_Parser = {
9643   #if PY_MAJOR_VERSION < 3
9644   0, /*bf_getreadbuffer*/
9645   #endif
9646   #if PY_MAJOR_VERSION < 3
9647   0, /*bf_getwritebuffer*/
9648   #endif
9649   #if PY_MAJOR_VERSION < 3
9650   0, /*bf_getsegcount*/
9651   #endif
9652   #if PY_MAJOR_VERSION < 3
9653   0, /*bf_getcharbuffer*/
9654   #endif
9655   #if PY_VERSION_HEX >= 0x02060000
9656   0, /*bf_getbuffer*/
9657   #endif
9658   #if PY_VERSION_HEX >= 0x02060000
9659   0, /*bf_releasebuffer*/
9660   #endif
9661 };
9662
9663 static PyTypeObject __pyx_type_6ctabix_Parser = {
9664   PyVarObject_HEAD_INIT(0, 0)
9665   __Pyx_NAMESTR("ctabix.Parser"), /*tp_name*/
9666   sizeof(struct __pyx_obj_6ctabix_Parser), /*tp_basicsize*/
9667   0, /*tp_itemsize*/
9668   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
9669   0, /*tp_print*/
9670   0, /*tp_getattr*/
9671   0, /*tp_setattr*/
9672   #if PY_MAJOR_VERSION < 3
9673   0, /*tp_compare*/
9674   #else
9675   0, /*reserved*/
9676   #endif
9677   0, /*tp_repr*/
9678   &__pyx_tp_as_number_Parser, /*tp_as_number*/
9679   &__pyx_tp_as_sequence_Parser, /*tp_as_sequence*/
9680   &__pyx_tp_as_mapping_Parser, /*tp_as_mapping*/
9681   0, /*tp_hash*/
9682   0, /*tp_call*/
9683   0, /*tp_str*/
9684   0, /*tp_getattro*/
9685   0, /*tp_setattro*/
9686   &__pyx_tp_as_buffer_Parser, /*tp_as_buffer*/
9687   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
9688   0, /*tp_doc*/
9689   0, /*tp_traverse*/
9690   0, /*tp_clear*/
9691   0, /*tp_richcompare*/
9692   0, /*tp_weaklistoffset*/
9693   0, /*tp_iter*/
9694   0, /*tp_iternext*/
9695   __pyx_methods_6ctabix_Parser, /*tp_methods*/
9696   0, /*tp_members*/
9697   0, /*tp_getset*/
9698   0, /*tp_base*/
9699   0, /*tp_dict*/
9700   0, /*tp_descr_get*/
9701   0, /*tp_descr_set*/
9702   0, /*tp_dictoffset*/
9703   0, /*tp_init*/
9704   0, /*tp_alloc*/
9705   __pyx_tp_new_6ctabix_Parser, /*tp_new*/
9706   0, /*tp_free*/
9707   0, /*tp_is_gc*/
9708   0, /*tp_bases*/
9709   0, /*tp_mro*/
9710   0, /*tp_cache*/
9711   0, /*tp_subclasses*/
9712   0, /*tp_weaklist*/
9713   0, /*tp_del*/
9714   #if PY_VERSION_HEX >= 0x02060000
9715   0, /*tp_version_tag*/
9716   #endif
9717 };
9718
9719 static PyObject *__pyx_tp_new_6ctabix_asTuple(PyTypeObject *t, PyObject *a, PyObject *k) {
9720   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
9721   if (!o) return 0;
9722   return o;
9723 }
9724
9725 static PyMethodDef __pyx_methods_6ctabix_asTuple[] = {
9726   {0, 0, 0, 0}
9727 };
9728
9729 static PyNumberMethods __pyx_tp_as_number_asTuple = {
9730   0, /*nb_add*/
9731   0, /*nb_subtract*/
9732   0, /*nb_multiply*/
9733   #if PY_MAJOR_VERSION < 3
9734   0, /*nb_divide*/
9735   #endif
9736   0, /*nb_remainder*/
9737   0, /*nb_divmod*/
9738   0, /*nb_power*/
9739   0, /*nb_negative*/
9740   0, /*nb_positive*/
9741   0, /*nb_absolute*/
9742   0, /*nb_nonzero*/
9743   0, /*nb_invert*/
9744   0, /*nb_lshift*/
9745   0, /*nb_rshift*/
9746   0, /*nb_and*/
9747   0, /*nb_xor*/
9748   0, /*nb_or*/
9749   #if PY_MAJOR_VERSION < 3
9750   0, /*nb_coerce*/
9751   #endif
9752   0, /*nb_int*/
9753   #if PY_MAJOR_VERSION < 3
9754   0, /*nb_long*/
9755   #else
9756   0, /*reserved*/
9757   #endif
9758   0, /*nb_float*/
9759   #if PY_MAJOR_VERSION < 3
9760   0, /*nb_oct*/
9761   #endif
9762   #if PY_MAJOR_VERSION < 3
9763   0, /*nb_hex*/
9764   #endif
9765   0, /*nb_inplace_add*/
9766   0, /*nb_inplace_subtract*/
9767   0, /*nb_inplace_multiply*/
9768   #if PY_MAJOR_VERSION < 3
9769   0, /*nb_inplace_divide*/
9770   #endif
9771   0, /*nb_inplace_remainder*/
9772   0, /*nb_inplace_power*/
9773   0, /*nb_inplace_lshift*/
9774   0, /*nb_inplace_rshift*/
9775   0, /*nb_inplace_and*/
9776   0, /*nb_inplace_xor*/
9777   0, /*nb_inplace_or*/
9778   0, /*nb_floor_divide*/
9779   0, /*nb_true_divide*/
9780   0, /*nb_inplace_floor_divide*/
9781   0, /*nb_inplace_true_divide*/
9782   #if PY_VERSION_HEX >= 0x02050000
9783   0, /*nb_index*/
9784   #endif
9785 };
9786
9787 static PySequenceMethods __pyx_tp_as_sequence_asTuple = {
9788   0, /*sq_length*/
9789   0, /*sq_concat*/
9790   0, /*sq_repeat*/
9791   0, /*sq_item*/
9792   0, /*sq_slice*/
9793   0, /*sq_ass_item*/
9794   0, /*sq_ass_slice*/
9795   0, /*sq_contains*/
9796   0, /*sq_inplace_concat*/
9797   0, /*sq_inplace_repeat*/
9798 };
9799
9800 static PyMappingMethods __pyx_tp_as_mapping_asTuple = {
9801   0, /*mp_length*/
9802   0, /*mp_subscript*/
9803   0, /*mp_ass_subscript*/
9804 };
9805
9806 static PyBufferProcs __pyx_tp_as_buffer_asTuple = {
9807   #if PY_MAJOR_VERSION < 3
9808   0, /*bf_getreadbuffer*/
9809   #endif
9810   #if PY_MAJOR_VERSION < 3
9811   0, /*bf_getwritebuffer*/
9812   #endif
9813   #if PY_MAJOR_VERSION < 3
9814   0, /*bf_getsegcount*/
9815   #endif
9816   #if PY_MAJOR_VERSION < 3
9817   0, /*bf_getcharbuffer*/
9818   #endif
9819   #if PY_VERSION_HEX >= 0x02060000
9820   0, /*bf_getbuffer*/
9821   #endif
9822   #if PY_VERSION_HEX >= 0x02060000
9823   0, /*bf_releasebuffer*/
9824   #endif
9825 };
9826
9827 static PyTypeObject __pyx_type_6ctabix_asTuple = {
9828   PyVarObject_HEAD_INIT(0, 0)
9829   __Pyx_NAMESTR("ctabix.asTuple"), /*tp_name*/
9830   sizeof(struct __pyx_obj_6ctabix_asTuple), /*tp_basicsize*/
9831   0, /*tp_itemsize*/
9832   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
9833   0, /*tp_print*/
9834   0, /*tp_getattr*/
9835   0, /*tp_setattr*/
9836   #if PY_MAJOR_VERSION < 3
9837   0, /*tp_compare*/
9838   #else
9839   0, /*reserved*/
9840   #endif
9841   0, /*tp_repr*/
9842   &__pyx_tp_as_number_asTuple, /*tp_as_number*/
9843   &__pyx_tp_as_sequence_asTuple, /*tp_as_sequence*/
9844   &__pyx_tp_as_mapping_asTuple, /*tp_as_mapping*/
9845   0, /*tp_hash*/
9846   __pyx_pw_6ctabix_7asTuple_1__call__, /*tp_call*/
9847   0, /*tp_str*/
9848   0, /*tp_getattro*/
9849   0, /*tp_setattro*/
9850   &__pyx_tp_as_buffer_asTuple, /*tp_as_buffer*/
9851   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
9852   __Pyx_DOCSTR("converts a :term:`tabix row` into a python tuple.\n\n    Access is by numeric index.\n    "), /*tp_doc*/
9853   0, /*tp_traverse*/
9854   0, /*tp_clear*/
9855   0, /*tp_richcompare*/
9856   0, /*tp_weaklistoffset*/
9857   0, /*tp_iter*/
9858   0, /*tp_iternext*/
9859   __pyx_methods_6ctabix_asTuple, /*tp_methods*/
9860   0, /*tp_members*/
9861   0, /*tp_getset*/
9862   0, /*tp_base*/
9863   0, /*tp_dict*/
9864   0, /*tp_descr_get*/
9865   0, /*tp_descr_set*/
9866   0, /*tp_dictoffset*/
9867   0, /*tp_init*/
9868   0, /*tp_alloc*/
9869   __pyx_tp_new_6ctabix_asTuple, /*tp_new*/
9870   0, /*tp_free*/
9871   0, /*tp_is_gc*/
9872   0, /*tp_bases*/
9873   0, /*tp_mro*/
9874   0, /*tp_cache*/
9875   0, /*tp_subclasses*/
9876   0, /*tp_weaklist*/
9877   0, /*tp_del*/
9878   #if PY_VERSION_HEX >= 0x02060000
9879   0, /*tp_version_tag*/
9880   #endif
9881 };
9882
9883 static PyObject *__pyx_tp_new_6ctabix_asGTF(PyTypeObject *t, PyObject *a, PyObject *k) {
9884   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
9885   if (!o) return 0;
9886   return o;
9887 }
9888
9889 static PyMethodDef __pyx_methods_6ctabix_asGTF[] = {
9890   {0, 0, 0, 0}
9891 };
9892
9893 static PyNumberMethods __pyx_tp_as_number_asGTF = {
9894   0, /*nb_add*/
9895   0, /*nb_subtract*/
9896   0, /*nb_multiply*/
9897   #if PY_MAJOR_VERSION < 3
9898   0, /*nb_divide*/
9899   #endif
9900   0, /*nb_remainder*/
9901   0, /*nb_divmod*/
9902   0, /*nb_power*/
9903   0, /*nb_negative*/
9904   0, /*nb_positive*/
9905   0, /*nb_absolute*/
9906   0, /*nb_nonzero*/
9907   0, /*nb_invert*/
9908   0, /*nb_lshift*/
9909   0, /*nb_rshift*/
9910   0, /*nb_and*/
9911   0, /*nb_xor*/
9912   0, /*nb_or*/
9913   #if PY_MAJOR_VERSION < 3
9914   0, /*nb_coerce*/
9915   #endif
9916   0, /*nb_int*/
9917   #if PY_MAJOR_VERSION < 3
9918   0, /*nb_long*/
9919   #else
9920   0, /*reserved*/
9921   #endif
9922   0, /*nb_float*/
9923   #if PY_MAJOR_VERSION < 3
9924   0, /*nb_oct*/
9925   #endif
9926   #if PY_MAJOR_VERSION < 3
9927   0, /*nb_hex*/
9928   #endif
9929   0, /*nb_inplace_add*/
9930   0, /*nb_inplace_subtract*/
9931   0, /*nb_inplace_multiply*/
9932   #if PY_MAJOR_VERSION < 3
9933   0, /*nb_inplace_divide*/
9934   #endif
9935   0, /*nb_inplace_remainder*/
9936   0, /*nb_inplace_power*/
9937   0, /*nb_inplace_lshift*/
9938   0, /*nb_inplace_rshift*/
9939   0, /*nb_inplace_and*/
9940   0, /*nb_inplace_xor*/
9941   0, /*nb_inplace_or*/
9942   0, /*nb_floor_divide*/
9943   0, /*nb_true_divide*/
9944   0, /*nb_inplace_floor_divide*/
9945   0, /*nb_inplace_true_divide*/
9946   #if PY_VERSION_HEX >= 0x02050000
9947   0, /*nb_index*/
9948   #endif
9949 };
9950
9951 static PySequenceMethods __pyx_tp_as_sequence_asGTF = {
9952   0, /*sq_length*/
9953   0, /*sq_concat*/
9954   0, /*sq_repeat*/
9955   0, /*sq_item*/
9956   0, /*sq_slice*/
9957   0, /*sq_ass_item*/
9958   0, /*sq_ass_slice*/
9959   0, /*sq_contains*/
9960   0, /*sq_inplace_concat*/
9961   0, /*sq_inplace_repeat*/
9962 };
9963
9964 static PyMappingMethods __pyx_tp_as_mapping_asGTF = {
9965   0, /*mp_length*/
9966   0, /*mp_subscript*/
9967   0, /*mp_ass_subscript*/
9968 };
9969
9970 static PyBufferProcs __pyx_tp_as_buffer_asGTF = {
9971   #if PY_MAJOR_VERSION < 3
9972   0, /*bf_getreadbuffer*/
9973   #endif
9974   #if PY_MAJOR_VERSION < 3
9975   0, /*bf_getwritebuffer*/
9976   #endif
9977   #if PY_MAJOR_VERSION < 3
9978   0, /*bf_getsegcount*/
9979   #endif
9980   #if PY_MAJOR_VERSION < 3
9981   0, /*bf_getcharbuffer*/
9982   #endif
9983   #if PY_VERSION_HEX >= 0x02060000
9984   0, /*bf_getbuffer*/
9985   #endif
9986   #if PY_VERSION_HEX >= 0x02060000
9987   0, /*bf_releasebuffer*/
9988   #endif
9989 };
9990
9991 static PyTypeObject __pyx_type_6ctabix_asGTF = {
9992   PyVarObject_HEAD_INIT(0, 0)
9993   __Pyx_NAMESTR("ctabix.asGTF"), /*tp_name*/
9994   sizeof(struct __pyx_obj_6ctabix_asGTF), /*tp_basicsize*/
9995   0, /*tp_itemsize*/
9996   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
9997   0, /*tp_print*/
9998   0, /*tp_getattr*/
9999   0, /*tp_setattr*/
10000   #if PY_MAJOR_VERSION < 3
10001   0, /*tp_compare*/
10002   #else
10003   0, /*reserved*/
10004   #endif
10005   0, /*tp_repr*/
10006   &__pyx_tp_as_number_asGTF, /*tp_as_number*/
10007   &__pyx_tp_as_sequence_asGTF, /*tp_as_sequence*/
10008   &__pyx_tp_as_mapping_asGTF, /*tp_as_mapping*/
10009   0, /*tp_hash*/
10010   __pyx_pw_6ctabix_5asGTF_1__call__, /*tp_call*/
10011   0, /*tp_str*/
10012   0, /*tp_getattro*/
10013   0, /*tp_setattro*/
10014   &__pyx_tp_as_buffer_asGTF, /*tp_as_buffer*/
10015   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
10016   __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*/
10017   0, /*tp_traverse*/
10018   0, /*tp_clear*/
10019   0, /*tp_richcompare*/
10020   0, /*tp_weaklistoffset*/
10021   0, /*tp_iter*/
10022   0, /*tp_iternext*/
10023   __pyx_methods_6ctabix_asGTF, /*tp_methods*/
10024   0, /*tp_members*/
10025   0, /*tp_getset*/
10026   0, /*tp_base*/
10027   0, /*tp_dict*/
10028   0, /*tp_descr_get*/
10029   0, /*tp_descr_set*/
10030   0, /*tp_dictoffset*/
10031   0, /*tp_init*/
10032   0, /*tp_alloc*/
10033   __pyx_tp_new_6ctabix_asGTF, /*tp_new*/
10034   0, /*tp_free*/
10035   0, /*tp_is_gc*/
10036   0, /*tp_bases*/
10037   0, /*tp_mro*/
10038   0, /*tp_cache*/
10039   0, /*tp_subclasses*/
10040   0, /*tp_weaklist*/
10041   0, /*tp_del*/
10042   #if PY_VERSION_HEX >= 0x02060000
10043   0, /*tp_version_tag*/
10044   #endif
10045 };
10046
10047 static PyObject *__pyx_tp_new_6ctabix_asBed(PyTypeObject *t, PyObject *a, PyObject *k) {
10048   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
10049   if (!o) return 0;
10050   return o;
10051 }
10052
10053 static PyMethodDef __pyx_methods_6ctabix_asBed[] = {
10054   {0, 0, 0, 0}
10055 };
10056
10057 static PyNumberMethods __pyx_tp_as_number_asBed = {
10058   0, /*nb_add*/
10059   0, /*nb_subtract*/
10060   0, /*nb_multiply*/
10061   #if PY_MAJOR_VERSION < 3
10062   0, /*nb_divide*/
10063   #endif
10064   0, /*nb_remainder*/
10065   0, /*nb_divmod*/
10066   0, /*nb_power*/
10067   0, /*nb_negative*/
10068   0, /*nb_positive*/
10069   0, /*nb_absolute*/
10070   0, /*nb_nonzero*/
10071   0, /*nb_invert*/
10072   0, /*nb_lshift*/
10073   0, /*nb_rshift*/
10074   0, /*nb_and*/
10075   0, /*nb_xor*/
10076   0, /*nb_or*/
10077   #if PY_MAJOR_VERSION < 3
10078   0, /*nb_coerce*/
10079   #endif
10080   0, /*nb_int*/
10081   #if PY_MAJOR_VERSION < 3
10082   0, /*nb_long*/
10083   #else
10084   0, /*reserved*/
10085   #endif
10086   0, /*nb_float*/
10087   #if PY_MAJOR_VERSION < 3
10088   0, /*nb_oct*/
10089   #endif
10090   #if PY_MAJOR_VERSION < 3
10091   0, /*nb_hex*/
10092   #endif
10093   0, /*nb_inplace_add*/
10094   0, /*nb_inplace_subtract*/
10095   0, /*nb_inplace_multiply*/
10096   #if PY_MAJOR_VERSION < 3
10097   0, /*nb_inplace_divide*/
10098   #endif
10099   0, /*nb_inplace_remainder*/
10100   0, /*nb_inplace_power*/
10101   0, /*nb_inplace_lshift*/
10102   0, /*nb_inplace_rshift*/
10103   0, /*nb_inplace_and*/
10104   0, /*nb_inplace_xor*/
10105   0, /*nb_inplace_or*/
10106   0, /*nb_floor_divide*/
10107   0, /*nb_true_divide*/
10108   0, /*nb_inplace_floor_divide*/
10109   0, /*nb_inplace_true_divide*/
10110   #if PY_VERSION_HEX >= 0x02050000
10111   0, /*nb_index*/
10112   #endif
10113 };
10114
10115 static PySequenceMethods __pyx_tp_as_sequence_asBed = {
10116   0, /*sq_length*/
10117   0, /*sq_concat*/
10118   0, /*sq_repeat*/
10119   0, /*sq_item*/
10120   0, /*sq_slice*/
10121   0, /*sq_ass_item*/
10122   0, /*sq_ass_slice*/
10123   0, /*sq_contains*/
10124   0, /*sq_inplace_concat*/
10125   0, /*sq_inplace_repeat*/
10126 };
10127
10128 static PyMappingMethods __pyx_tp_as_mapping_asBed = {
10129   0, /*mp_length*/
10130   0, /*mp_subscript*/
10131   0, /*mp_ass_subscript*/
10132 };
10133
10134 static PyBufferProcs __pyx_tp_as_buffer_asBed = {
10135   #if PY_MAJOR_VERSION < 3
10136   0, /*bf_getreadbuffer*/
10137   #endif
10138   #if PY_MAJOR_VERSION < 3
10139   0, /*bf_getwritebuffer*/
10140   #endif
10141   #if PY_MAJOR_VERSION < 3
10142   0, /*bf_getsegcount*/
10143   #endif
10144   #if PY_MAJOR_VERSION < 3
10145   0, /*bf_getcharbuffer*/
10146   #endif
10147   #if PY_VERSION_HEX >= 0x02060000
10148   0, /*bf_getbuffer*/
10149   #endif
10150   #if PY_VERSION_HEX >= 0x02060000
10151   0, /*bf_releasebuffer*/
10152   #endif
10153 };
10154
10155 static PyTypeObject __pyx_type_6ctabix_asBed = {
10156   PyVarObject_HEAD_INIT(0, 0)
10157   __Pyx_NAMESTR("ctabix.asBed"), /*tp_name*/
10158   sizeof(struct __pyx_obj_6ctabix_asBed), /*tp_basicsize*/
10159   0, /*tp_itemsize*/
10160   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
10161   0, /*tp_print*/
10162   0, /*tp_getattr*/
10163   0, /*tp_setattr*/
10164   #if PY_MAJOR_VERSION < 3
10165   0, /*tp_compare*/
10166   #else
10167   0, /*reserved*/
10168   #endif
10169   0, /*tp_repr*/
10170   &__pyx_tp_as_number_asBed, /*tp_as_number*/
10171   &__pyx_tp_as_sequence_asBed, /*tp_as_sequence*/
10172   &__pyx_tp_as_mapping_asBed, /*tp_as_mapping*/
10173   0, /*tp_hash*/
10174   __pyx_pw_6ctabix_5asBed_1__call__, /*tp_call*/
10175   0, /*tp_str*/
10176   0, /*tp_getattro*/
10177   0, /*tp_setattro*/
10178   &__pyx_tp_as_buffer_asBed, /*tp_as_buffer*/
10179   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
10180   __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*/
10181   0, /*tp_traverse*/
10182   0, /*tp_clear*/
10183   0, /*tp_richcompare*/
10184   0, /*tp_weaklistoffset*/
10185   0, /*tp_iter*/
10186   0, /*tp_iternext*/
10187   __pyx_methods_6ctabix_asBed, /*tp_methods*/
10188   0, /*tp_members*/
10189   0, /*tp_getset*/
10190   0, /*tp_base*/
10191   0, /*tp_dict*/
10192   0, /*tp_descr_get*/
10193   0, /*tp_descr_set*/
10194   0, /*tp_dictoffset*/
10195   0, /*tp_init*/
10196   0, /*tp_alloc*/
10197   __pyx_tp_new_6ctabix_asBed, /*tp_new*/
10198   0, /*tp_free*/
10199   0, /*tp_is_gc*/
10200   0, /*tp_bases*/
10201   0, /*tp_mro*/
10202   0, /*tp_cache*/
10203   0, /*tp_subclasses*/
10204   0, /*tp_weaklist*/
10205   0, /*tp_del*/
10206   #if PY_VERSION_HEX >= 0x02060000
10207   0, /*tp_version_tag*/
10208   #endif
10209 };
10210
10211 static PyObject *__pyx_tp_new_6ctabix_asVCF(PyTypeObject *t, PyObject *a, PyObject *k) {
10212   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
10213   if (!o) return 0;
10214   return o;
10215 }
10216
10217 static PyMethodDef __pyx_methods_6ctabix_asVCF[] = {
10218   {0, 0, 0, 0}
10219 };
10220
10221 static PyNumberMethods __pyx_tp_as_number_asVCF = {
10222   0, /*nb_add*/
10223   0, /*nb_subtract*/
10224   0, /*nb_multiply*/
10225   #if PY_MAJOR_VERSION < 3
10226   0, /*nb_divide*/
10227   #endif
10228   0, /*nb_remainder*/
10229   0, /*nb_divmod*/
10230   0, /*nb_power*/
10231   0, /*nb_negative*/
10232   0, /*nb_positive*/
10233   0, /*nb_absolute*/
10234   0, /*nb_nonzero*/
10235   0, /*nb_invert*/
10236   0, /*nb_lshift*/
10237   0, /*nb_rshift*/
10238   0, /*nb_and*/
10239   0, /*nb_xor*/
10240   0, /*nb_or*/
10241   #if PY_MAJOR_VERSION < 3
10242   0, /*nb_coerce*/
10243   #endif
10244   0, /*nb_int*/
10245   #if PY_MAJOR_VERSION < 3
10246   0, /*nb_long*/
10247   #else
10248   0, /*reserved*/
10249   #endif
10250   0, /*nb_float*/
10251   #if PY_MAJOR_VERSION < 3
10252   0, /*nb_oct*/
10253   #endif
10254   #if PY_MAJOR_VERSION < 3
10255   0, /*nb_hex*/
10256   #endif
10257   0, /*nb_inplace_add*/
10258   0, /*nb_inplace_subtract*/
10259   0, /*nb_inplace_multiply*/
10260   #if PY_MAJOR_VERSION < 3
10261   0, /*nb_inplace_divide*/
10262   #endif
10263   0, /*nb_inplace_remainder*/
10264   0, /*nb_inplace_power*/
10265   0, /*nb_inplace_lshift*/
10266   0, /*nb_inplace_rshift*/
10267   0, /*nb_inplace_and*/
10268   0, /*nb_inplace_xor*/
10269   0, /*nb_inplace_or*/
10270   0, /*nb_floor_divide*/
10271   0, /*nb_true_divide*/
10272   0, /*nb_inplace_floor_divide*/
10273   0, /*nb_inplace_true_divide*/
10274   #if PY_VERSION_HEX >= 0x02050000
10275   0, /*nb_index*/
10276   #endif
10277 };
10278
10279 static PySequenceMethods __pyx_tp_as_sequence_asVCF = {
10280   0, /*sq_length*/
10281   0, /*sq_concat*/
10282   0, /*sq_repeat*/
10283   0, /*sq_item*/
10284   0, /*sq_slice*/
10285   0, /*sq_ass_item*/
10286   0, /*sq_ass_slice*/
10287   0, /*sq_contains*/
10288   0, /*sq_inplace_concat*/
10289   0, /*sq_inplace_repeat*/
10290 };
10291
10292 static PyMappingMethods __pyx_tp_as_mapping_asVCF = {
10293   0, /*mp_length*/
10294   0, /*mp_subscript*/
10295   0, /*mp_ass_subscript*/
10296 };
10297
10298 static PyBufferProcs __pyx_tp_as_buffer_asVCF = {
10299   #if PY_MAJOR_VERSION < 3
10300   0, /*bf_getreadbuffer*/
10301   #endif
10302   #if PY_MAJOR_VERSION < 3
10303   0, /*bf_getwritebuffer*/
10304   #endif
10305   #if PY_MAJOR_VERSION < 3
10306   0, /*bf_getsegcount*/
10307   #endif
10308   #if PY_MAJOR_VERSION < 3
10309   0, /*bf_getcharbuffer*/
10310   #endif
10311   #if PY_VERSION_HEX >= 0x02060000
10312   0, /*bf_getbuffer*/
10313   #endif
10314   #if PY_VERSION_HEX >= 0x02060000
10315   0, /*bf_releasebuffer*/
10316   #endif
10317 };
10318
10319 static PyTypeObject __pyx_type_6ctabix_asVCF = {
10320   PyVarObject_HEAD_INIT(0, 0)
10321   __Pyx_NAMESTR("ctabix.asVCF"), /*tp_name*/
10322   sizeof(struct __pyx_obj_6ctabix_asVCF), /*tp_basicsize*/
10323   0, /*tp_itemsize*/
10324   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
10325   0, /*tp_print*/
10326   0, /*tp_getattr*/
10327   0, /*tp_setattr*/
10328   #if PY_MAJOR_VERSION < 3
10329   0, /*tp_compare*/
10330   #else
10331   0, /*reserved*/
10332   #endif
10333   0, /*tp_repr*/
10334   &__pyx_tp_as_number_asVCF, /*tp_as_number*/
10335   &__pyx_tp_as_sequence_asVCF, /*tp_as_sequence*/
10336   &__pyx_tp_as_mapping_asVCF, /*tp_as_mapping*/
10337   0, /*tp_hash*/
10338   __pyx_pw_6ctabix_5asVCF_1__call__, /*tp_call*/
10339   0, /*tp_str*/
10340   0, /*tp_getattro*/
10341   0, /*tp_setattro*/
10342   &__pyx_tp_as_buffer_asVCF, /*tp_as_buffer*/
10343   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
10344   __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*/
10345   0, /*tp_traverse*/
10346   0, /*tp_clear*/
10347   0, /*tp_richcompare*/
10348   0, /*tp_weaklistoffset*/
10349   0, /*tp_iter*/
10350   0, /*tp_iternext*/
10351   __pyx_methods_6ctabix_asVCF, /*tp_methods*/
10352   0, /*tp_members*/
10353   0, /*tp_getset*/
10354   0, /*tp_base*/
10355   0, /*tp_dict*/
10356   0, /*tp_descr_get*/
10357   0, /*tp_descr_set*/
10358   0, /*tp_dictoffset*/
10359   0, /*tp_init*/
10360   0, /*tp_alloc*/
10361   __pyx_tp_new_6ctabix_asVCF, /*tp_new*/
10362   0, /*tp_free*/
10363   0, /*tp_is_gc*/
10364   0, /*tp_bases*/
10365   0, /*tp_mro*/
10366   0, /*tp_cache*/
10367   0, /*tp_subclasses*/
10368   0, /*tp_weaklist*/
10369   0, /*tp_del*/
10370   #if PY_VERSION_HEX >= 0x02060000
10371   0, /*tp_version_tag*/
10372   #endif
10373 };
10374
10375 static PyObject *__pyx_tp_new_6ctabix_TabixIteratorParsed(PyTypeObject *t, PyObject *a, PyObject *k) {
10376   struct __pyx_obj_6ctabix_TabixIteratorParsed *p;
10377   PyObject *o = (*t->tp_alloc)(t, 0);
10378   if (!o) return 0;
10379   p = ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)o);
10380   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
10381   if (__pyx_pw_6ctabix_19TabixIteratorParsed_1__cinit__(o, a, k) < 0) {
10382     Py_DECREF(o); o = 0;
10383   }
10384   return o;
10385 }
10386
10387 static void __pyx_tp_dealloc_6ctabix_TabixIteratorParsed(PyObject *o) {
10388   struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o;
10389   {
10390     PyObject *etype, *eval, *etb;
10391     PyErr_Fetch(&etype, &eval, &etb);
10392     ++Py_REFCNT(o);
10393     __pyx_pw_6ctabix_19TabixIteratorParsed_7__dealloc__(o);
10394     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
10395     --Py_REFCNT(o);
10396     PyErr_Restore(etype, eval, etb);
10397   }
10398   Py_CLEAR(p->parser);
10399   (*Py_TYPE(o)->tp_free)(o);
10400 }
10401
10402 static int __pyx_tp_traverse_6ctabix_TabixIteratorParsed(PyObject *o, visitproc v, void *a) {
10403   int e;
10404   struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o;
10405   if (p->parser) {
10406     e = (*v)(((PyObject*)p->parser), a); if (e) return e;
10407   }
10408   return 0;
10409 }
10410
10411 static int __pyx_tp_clear_6ctabix_TabixIteratorParsed(PyObject *o) {
10412   struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o;
10413   PyObject* tmp;
10414   tmp = ((PyObject*)p->parser);
10415   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
10416   Py_XDECREF(tmp);
10417   return 0;
10418 }
10419
10420 static PyMethodDef __pyx_methods_6ctabix_TabixIteratorParsed[] = {
10421   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6ctabix_19TabixIteratorParsed_5__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_19TabixIteratorParsed_4__next__)},
10422   {0, 0, 0, 0}
10423 };
10424
10425 static PyNumberMethods __pyx_tp_as_number_TabixIteratorParsed = {
10426   0, /*nb_add*/
10427   0, /*nb_subtract*/
10428   0, /*nb_multiply*/
10429   #if PY_MAJOR_VERSION < 3
10430   0, /*nb_divide*/
10431   #endif
10432   0, /*nb_remainder*/
10433   0, /*nb_divmod*/
10434   0, /*nb_power*/
10435   0, /*nb_negative*/
10436   0, /*nb_positive*/
10437   0, /*nb_absolute*/
10438   0, /*nb_nonzero*/
10439   0, /*nb_invert*/
10440   0, /*nb_lshift*/
10441   0, /*nb_rshift*/
10442   0, /*nb_and*/
10443   0, /*nb_xor*/
10444   0, /*nb_or*/
10445   #if PY_MAJOR_VERSION < 3
10446   0, /*nb_coerce*/
10447   #endif
10448   0, /*nb_int*/
10449   #if PY_MAJOR_VERSION < 3
10450   0, /*nb_long*/
10451   #else
10452   0, /*reserved*/
10453   #endif
10454   0, /*nb_float*/
10455   #if PY_MAJOR_VERSION < 3
10456   0, /*nb_oct*/
10457   #endif
10458   #if PY_MAJOR_VERSION < 3
10459   0, /*nb_hex*/
10460   #endif
10461   0, /*nb_inplace_add*/
10462   0, /*nb_inplace_subtract*/
10463   0, /*nb_inplace_multiply*/
10464   #if PY_MAJOR_VERSION < 3
10465   0, /*nb_inplace_divide*/
10466   #endif
10467   0, /*nb_inplace_remainder*/
10468   0, /*nb_inplace_power*/
10469   0, /*nb_inplace_lshift*/
10470   0, /*nb_inplace_rshift*/
10471   0, /*nb_inplace_and*/
10472   0, /*nb_inplace_xor*/
10473   0, /*nb_inplace_or*/
10474   0, /*nb_floor_divide*/
10475   0, /*nb_true_divide*/
10476   0, /*nb_inplace_floor_divide*/
10477   0, /*nb_inplace_true_divide*/
10478   #if PY_VERSION_HEX >= 0x02050000
10479   0, /*nb_index*/
10480   #endif
10481 };
10482
10483 static PySequenceMethods __pyx_tp_as_sequence_TabixIteratorParsed = {
10484   0, /*sq_length*/
10485   0, /*sq_concat*/
10486   0, /*sq_repeat*/
10487   0, /*sq_item*/
10488   0, /*sq_slice*/
10489   0, /*sq_ass_item*/
10490   0, /*sq_ass_slice*/
10491   0, /*sq_contains*/
10492   0, /*sq_inplace_concat*/
10493   0, /*sq_inplace_repeat*/
10494 };
10495
10496 static PyMappingMethods __pyx_tp_as_mapping_TabixIteratorParsed = {
10497   0, /*mp_length*/
10498   0, /*mp_subscript*/
10499   0, /*mp_ass_subscript*/
10500 };
10501
10502 static PyBufferProcs __pyx_tp_as_buffer_TabixIteratorParsed = {
10503   #if PY_MAJOR_VERSION < 3
10504   0, /*bf_getreadbuffer*/
10505   #endif
10506   #if PY_MAJOR_VERSION < 3
10507   0, /*bf_getwritebuffer*/
10508   #endif
10509   #if PY_MAJOR_VERSION < 3
10510   0, /*bf_getsegcount*/
10511   #endif
10512   #if PY_MAJOR_VERSION < 3
10513   0, /*bf_getcharbuffer*/
10514   #endif
10515   #if PY_VERSION_HEX >= 0x02060000
10516   0, /*bf_getbuffer*/
10517   #endif
10518   #if PY_VERSION_HEX >= 0x02060000
10519   0, /*bf_releasebuffer*/
10520   #endif
10521 };
10522
10523 static PyTypeObject __pyx_type_6ctabix_TabixIteratorParsed = {
10524   PyVarObject_HEAD_INIT(0, 0)
10525   __Pyx_NAMESTR("ctabix.TabixIteratorParsed"), /*tp_name*/
10526   sizeof(struct __pyx_obj_6ctabix_TabixIteratorParsed), /*tp_basicsize*/
10527   0, /*tp_itemsize*/
10528   __pyx_tp_dealloc_6ctabix_TabixIteratorParsed, /*tp_dealloc*/
10529   0, /*tp_print*/
10530   0, /*tp_getattr*/
10531   0, /*tp_setattr*/
10532   #if PY_MAJOR_VERSION < 3
10533   0, /*tp_compare*/
10534   #else
10535   0, /*reserved*/
10536   #endif
10537   0, /*tp_repr*/
10538   &__pyx_tp_as_number_TabixIteratorParsed, /*tp_as_number*/
10539   &__pyx_tp_as_sequence_TabixIteratorParsed, /*tp_as_sequence*/
10540   &__pyx_tp_as_mapping_TabixIteratorParsed, /*tp_as_mapping*/
10541   0, /*tp_hash*/
10542   0, /*tp_call*/
10543   0, /*tp_str*/
10544   0, /*tp_getattro*/
10545   0, /*tp_setattro*/
10546   &__pyx_tp_as_buffer_TabixIteratorParsed, /*tp_as_buffer*/
10547   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
10548   __Pyx_DOCSTR("iterates over mapped reads in a region.\n\n    Returns parsed data.\n    "), /*tp_doc*/
10549   __pyx_tp_traverse_6ctabix_TabixIteratorParsed, /*tp_traverse*/
10550   __pyx_tp_clear_6ctabix_TabixIteratorParsed, /*tp_clear*/
10551   0, /*tp_richcompare*/
10552   0, /*tp_weaklistoffset*/
10553   __pyx_pw_6ctabix_19TabixIteratorParsed_3__iter__, /*tp_iter*/
10554   __pyx_pw_6ctabix_19TabixIteratorParsed_5__next__, /*tp_iternext*/
10555   __pyx_methods_6ctabix_TabixIteratorParsed, /*tp_methods*/
10556   0, /*tp_members*/
10557   0, /*tp_getset*/
10558   0, /*tp_base*/
10559   0, /*tp_dict*/
10560   0, /*tp_descr_get*/
10561   0, /*tp_descr_set*/
10562   0, /*tp_dictoffset*/
10563   0, /*tp_init*/
10564   0, /*tp_alloc*/
10565   __pyx_tp_new_6ctabix_TabixIteratorParsed, /*tp_new*/
10566   0, /*tp_free*/
10567   0, /*tp_is_gc*/
10568   0, /*tp_bases*/
10569   0, /*tp_mro*/
10570   0, /*tp_cache*/
10571   0, /*tp_subclasses*/
10572   0, /*tp_weaklist*/
10573   0, /*tp_del*/
10574   #if PY_VERSION_HEX >= 0x02060000
10575   0, /*tp_version_tag*/
10576   #endif
10577 };
10578 static struct __pyx_vtabstruct_6ctabix_tabix_inplace_iterator __pyx_vtable_6ctabix_tabix_inplace_iterator;
10579
10580 static PyObject *__pyx_tp_new_6ctabix_tabix_inplace_iterator(PyTypeObject *t, PyObject *a, PyObject *k) {
10581   struct __pyx_obj_6ctabix_tabix_inplace_iterator *p;
10582   PyObject *o = (*t->tp_alloc)(t, 0);
10583   if (!o) return 0;
10584   p = ((struct __pyx_obj_6ctabix_tabix_inplace_iterator *)o);
10585   p->__pyx_vtab = __pyx_vtabptr_6ctabix_tabix_inplace_iterator;
10586   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
10587   if (__pyx_pw_6ctabix_22tabix_inplace_iterator_1__cinit__(o, a, k) < 0) {
10588     Py_DECREF(o); o = 0;
10589   }
10590   return o;
10591 }
10592
10593 static void __pyx_tp_dealloc_6ctabix_tabix_inplace_iterator(PyObject *o) {
10594   struct __pyx_obj_6ctabix_tabix_inplace_iterator *p = (struct __pyx_obj_6ctabix_tabix_inplace_iterator *)o;
10595   {
10596     PyObject *etype, *eval, *etb;
10597     PyErr_Fetch(&etype, &eval, &etb);
10598     ++Py_REFCNT(o);
10599     __pyx_pw_6ctabix_22tabix_inplace_iterator_5__dealloc__(o);
10600     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
10601     --Py_REFCNT(o);
10602     PyErr_Restore(etype, eval, etb);
10603   }
10604   Py_CLEAR(p->parser);
10605   (*Py_TYPE(o)->tp_free)(o);
10606 }
10607
10608 static int __pyx_tp_traverse_6ctabix_tabix_inplace_iterator(PyObject *o, visitproc v, void *a) {
10609   int e;
10610   struct __pyx_obj_6ctabix_tabix_inplace_iterator *p = (struct __pyx_obj_6ctabix_tabix_inplace_iterator *)o;
10611   if (p->parser) {
10612     e = (*v)(((PyObject*)p->parser), a); if (e) return e;
10613   }
10614   return 0;
10615 }
10616
10617 static int __pyx_tp_clear_6ctabix_tabix_inplace_iterator(PyObject *o) {
10618   struct __pyx_obj_6ctabix_tabix_inplace_iterator *p = (struct __pyx_obj_6ctabix_tabix_inplace_iterator *)o;
10619   PyObject* tmp;
10620   tmp = ((PyObject*)p->parser);
10621   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
10622   Py_XDECREF(tmp);
10623   return 0;
10624 }
10625
10626 static PyMethodDef __pyx_methods_6ctabix_tabix_inplace_iterator[] = {
10627   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6ctabix_22tabix_inplace_iterator_7__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
10628   {0, 0, 0, 0}
10629 };
10630
10631 static PyNumberMethods __pyx_tp_as_number_tabix_inplace_iterator = {
10632   0, /*nb_add*/
10633   0, /*nb_subtract*/
10634   0, /*nb_multiply*/
10635   #if PY_MAJOR_VERSION < 3
10636   0, /*nb_divide*/
10637   #endif
10638   0, /*nb_remainder*/
10639   0, /*nb_divmod*/
10640   0, /*nb_power*/
10641   0, /*nb_negative*/
10642   0, /*nb_positive*/
10643   0, /*nb_absolute*/
10644   0, /*nb_nonzero*/
10645   0, /*nb_invert*/
10646   0, /*nb_lshift*/
10647   0, /*nb_rshift*/
10648   0, /*nb_and*/
10649   0, /*nb_xor*/
10650   0, /*nb_or*/
10651   #if PY_MAJOR_VERSION < 3
10652   0, /*nb_coerce*/
10653   #endif
10654   0, /*nb_int*/
10655   #if PY_MAJOR_VERSION < 3
10656   0, /*nb_long*/
10657   #else
10658   0, /*reserved*/
10659   #endif
10660   0, /*nb_float*/
10661   #if PY_MAJOR_VERSION < 3
10662   0, /*nb_oct*/
10663   #endif
10664   #if PY_MAJOR_VERSION < 3
10665   0, /*nb_hex*/
10666   #endif
10667   0, /*nb_inplace_add*/
10668   0, /*nb_inplace_subtract*/
10669   0, /*nb_inplace_multiply*/
10670   #if PY_MAJOR_VERSION < 3
10671   0, /*nb_inplace_divide*/
10672   #endif
10673   0, /*nb_inplace_remainder*/
10674   0, /*nb_inplace_power*/
10675   0, /*nb_inplace_lshift*/
10676   0, /*nb_inplace_rshift*/
10677   0, /*nb_inplace_and*/
10678   0, /*nb_inplace_xor*/
10679   0, /*nb_inplace_or*/
10680   0, /*nb_floor_divide*/
10681   0, /*nb_true_divide*/
10682   0, /*nb_inplace_floor_divide*/
10683   0, /*nb_inplace_true_divide*/
10684   #if PY_VERSION_HEX >= 0x02050000
10685   0, /*nb_index*/
10686   #endif
10687 };
10688
10689 static PySequenceMethods __pyx_tp_as_sequence_tabix_inplace_iterator = {
10690   0, /*sq_length*/
10691   0, /*sq_concat*/
10692   0, /*sq_repeat*/
10693   0, /*sq_item*/
10694   0, /*sq_slice*/
10695   0, /*sq_ass_item*/
10696   0, /*sq_ass_slice*/
10697   0, /*sq_contains*/
10698   0, /*sq_inplace_concat*/
10699   0, /*sq_inplace_repeat*/
10700 };
10701
10702 static PyMappingMethods __pyx_tp_as_mapping_tabix_inplace_iterator = {
10703   0, /*mp_length*/
10704   0, /*mp_subscript*/
10705   0, /*mp_ass_subscript*/
10706 };
10707
10708 static PyBufferProcs __pyx_tp_as_buffer_tabix_inplace_iterator = {
10709   #if PY_MAJOR_VERSION < 3
10710   0, /*bf_getreadbuffer*/
10711   #endif
10712   #if PY_MAJOR_VERSION < 3
10713   0, /*bf_getwritebuffer*/
10714   #endif
10715   #if PY_MAJOR_VERSION < 3
10716   0, /*bf_getsegcount*/
10717   #endif
10718   #if PY_MAJOR_VERSION < 3
10719   0, /*bf_getcharbuffer*/
10720   #endif
10721   #if PY_VERSION_HEX >= 0x02060000
10722   0, /*bf_getbuffer*/
10723   #endif
10724   #if PY_VERSION_HEX >= 0x02060000
10725   0, /*bf_releasebuffer*/
10726   #endif
10727 };
10728
10729 static PyTypeObject __pyx_type_6ctabix_tabix_inplace_iterator = {
10730   PyVarObject_HEAD_INIT(0, 0)
10731   __Pyx_NAMESTR("ctabix.tabix_inplace_iterator"), /*tp_name*/
10732   sizeof(struct __pyx_obj_6ctabix_tabix_inplace_iterator), /*tp_basicsize*/
10733   0, /*tp_itemsize*/
10734   __pyx_tp_dealloc_6ctabix_tabix_inplace_iterator, /*tp_dealloc*/
10735   0, /*tp_print*/
10736   0, /*tp_getattr*/
10737   0, /*tp_setattr*/
10738   #if PY_MAJOR_VERSION < 3
10739   0, /*tp_compare*/
10740   #else
10741   0, /*reserved*/
10742   #endif
10743   0, /*tp_repr*/
10744   &__pyx_tp_as_number_tabix_inplace_iterator, /*tp_as_number*/
10745   &__pyx_tp_as_sequence_tabix_inplace_iterator, /*tp_as_sequence*/
10746   &__pyx_tp_as_mapping_tabix_inplace_iterator, /*tp_as_mapping*/
10747   0, /*tp_hash*/
10748   0, /*tp_call*/
10749   0, /*tp_str*/
10750   0, /*tp_getattro*/
10751   0, /*tp_setattro*/
10752   &__pyx_tp_as_buffer_tabix_inplace_iterator, /*tp_as_buffer*/
10753   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
10754   __Pyx_DOCSTR("iterate over ``infile``.\n\n    This iterator is not safe. If the :meth:`__next__()` method is called \n    after ``infile`` is closed, the result is undefined (see ``fclose()``).\n\n    The iterator might either raise a StopIteration or segfault.\n    "), /*tp_doc*/
10755   __pyx_tp_traverse_6ctabix_tabix_inplace_iterator, /*tp_traverse*/
10756   __pyx_tp_clear_6ctabix_tabix_inplace_iterator, /*tp_clear*/
10757   0, /*tp_richcompare*/
10758   0, /*tp_weaklistoffset*/
10759   __pyx_pw_6ctabix_22tabix_inplace_iterator_3__iter__, /*tp_iter*/
10760   __pyx_pw_6ctabix_22tabix_inplace_iterator_7__next__, /*tp_iternext*/
10761   __pyx_methods_6ctabix_tabix_inplace_iterator, /*tp_methods*/
10762   0, /*tp_members*/
10763   0, /*tp_getset*/
10764   0, /*tp_base*/
10765   0, /*tp_dict*/
10766   0, /*tp_descr_get*/
10767   0, /*tp_descr_set*/
10768   0, /*tp_dictoffset*/
10769   0, /*tp_init*/
10770   0, /*tp_alloc*/
10771   __pyx_tp_new_6ctabix_tabix_inplace_iterator, /*tp_new*/
10772   0, /*tp_free*/
10773   0, /*tp_is_gc*/
10774   0, /*tp_bases*/
10775   0, /*tp_mro*/
10776   0, /*tp_cache*/
10777   0, /*tp_subclasses*/
10778   0, /*tp_weaklist*/
10779   0, /*tp_del*/
10780   #if PY_VERSION_HEX >= 0x02060000
10781   0, /*tp_version_tag*/
10782   #endif
10783 };
10784 static struct __pyx_vtabstruct_6ctabix_tabix_copy_iterator __pyx_vtable_6ctabix_tabix_copy_iterator;
10785
10786 static PyObject *__pyx_tp_new_6ctabix_tabix_copy_iterator(PyTypeObject *t, PyObject *a, PyObject *k) {
10787   struct __pyx_obj_6ctabix_tabix_copy_iterator *p;
10788   PyObject *o = (*t->tp_alloc)(t, 0);
10789   if (!o) return 0;
10790   p = ((struct __pyx_obj_6ctabix_tabix_copy_iterator *)o);
10791   p->__pyx_vtab = __pyx_vtabptr_6ctabix_tabix_copy_iterator;
10792   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
10793   if (__pyx_pw_6ctabix_19tabix_copy_iterator_1__cinit__(o, a, k) < 0) {
10794     Py_DECREF(o); o = 0;
10795   }
10796   return o;
10797 }
10798
10799 static void __pyx_tp_dealloc_6ctabix_tabix_copy_iterator(PyObject *o) {
10800   struct __pyx_obj_6ctabix_tabix_copy_iterator *p = (struct __pyx_obj_6ctabix_tabix_copy_iterator *)o;
10801   Py_CLEAR(p->parser);
10802   (*Py_TYPE(o)->tp_free)(o);
10803 }
10804
10805 static int __pyx_tp_traverse_6ctabix_tabix_copy_iterator(PyObject *o, visitproc v, void *a) {
10806   int e;
10807   struct __pyx_obj_6ctabix_tabix_copy_iterator *p = (struct __pyx_obj_6ctabix_tabix_copy_iterator *)o;
10808   if (p->parser) {
10809     e = (*v)(((PyObject*)p->parser), a); if (e) return e;
10810   }
10811   return 0;
10812 }
10813
10814 static int __pyx_tp_clear_6ctabix_tabix_copy_iterator(PyObject *o) {
10815   struct __pyx_obj_6ctabix_tabix_copy_iterator *p = (struct __pyx_obj_6ctabix_tabix_copy_iterator *)o;
10816   PyObject* tmp;
10817   tmp = ((PyObject*)p->parser);
10818   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
10819   Py_XDECREF(tmp);
10820   return 0;
10821 }
10822
10823 static PyMethodDef __pyx_methods_6ctabix_tabix_copy_iterator[] = {
10824   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6ctabix_19tabix_copy_iterator_5__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
10825   {0, 0, 0, 0}
10826 };
10827
10828 static PyNumberMethods __pyx_tp_as_number_tabix_copy_iterator = {
10829   0, /*nb_add*/
10830   0, /*nb_subtract*/
10831   0, /*nb_multiply*/
10832   #if PY_MAJOR_VERSION < 3
10833   0, /*nb_divide*/
10834   #endif
10835   0, /*nb_remainder*/
10836   0, /*nb_divmod*/
10837   0, /*nb_power*/
10838   0, /*nb_negative*/
10839   0, /*nb_positive*/
10840   0, /*nb_absolute*/
10841   0, /*nb_nonzero*/
10842   0, /*nb_invert*/
10843   0, /*nb_lshift*/
10844   0, /*nb_rshift*/
10845   0, /*nb_and*/
10846   0, /*nb_xor*/
10847   0, /*nb_or*/
10848   #if PY_MAJOR_VERSION < 3
10849   0, /*nb_coerce*/
10850   #endif
10851   0, /*nb_int*/
10852   #if PY_MAJOR_VERSION < 3
10853   0, /*nb_long*/
10854   #else
10855   0, /*reserved*/
10856   #endif
10857   0, /*nb_float*/
10858   #if PY_MAJOR_VERSION < 3
10859   0, /*nb_oct*/
10860   #endif
10861   #if PY_MAJOR_VERSION < 3
10862   0, /*nb_hex*/
10863   #endif
10864   0, /*nb_inplace_add*/
10865   0, /*nb_inplace_subtract*/
10866   0, /*nb_inplace_multiply*/
10867   #if PY_MAJOR_VERSION < 3
10868   0, /*nb_inplace_divide*/
10869   #endif
10870   0, /*nb_inplace_remainder*/
10871   0, /*nb_inplace_power*/
10872   0, /*nb_inplace_lshift*/
10873   0, /*nb_inplace_rshift*/
10874   0, /*nb_inplace_and*/
10875   0, /*nb_inplace_xor*/
10876   0, /*nb_inplace_or*/
10877   0, /*nb_floor_divide*/
10878   0, /*nb_true_divide*/
10879   0, /*nb_inplace_floor_divide*/
10880   0, /*nb_inplace_true_divide*/
10881   #if PY_VERSION_HEX >= 0x02050000
10882   0, /*nb_index*/
10883   #endif
10884 };
10885
10886 static PySequenceMethods __pyx_tp_as_sequence_tabix_copy_iterator = {
10887   0, /*sq_length*/
10888   0, /*sq_concat*/
10889   0, /*sq_repeat*/
10890   0, /*sq_item*/
10891   0, /*sq_slice*/
10892   0, /*sq_ass_item*/
10893   0, /*sq_ass_slice*/
10894   0, /*sq_contains*/
10895   0, /*sq_inplace_concat*/
10896   0, /*sq_inplace_repeat*/
10897 };
10898
10899 static PyMappingMethods __pyx_tp_as_mapping_tabix_copy_iterator = {
10900   0, /*mp_length*/
10901   0, /*mp_subscript*/
10902   0, /*mp_ass_subscript*/
10903 };
10904
10905 static PyBufferProcs __pyx_tp_as_buffer_tabix_copy_iterator = {
10906   #if PY_MAJOR_VERSION < 3
10907   0, /*bf_getreadbuffer*/
10908   #endif
10909   #if PY_MAJOR_VERSION < 3
10910   0, /*bf_getwritebuffer*/
10911   #endif
10912   #if PY_MAJOR_VERSION < 3
10913   0, /*bf_getsegcount*/
10914   #endif
10915   #if PY_MAJOR_VERSION < 3
10916   0, /*bf_getcharbuffer*/
10917   #endif
10918   #if PY_VERSION_HEX >= 0x02060000
10919   0, /*bf_getbuffer*/
10920   #endif
10921   #if PY_VERSION_HEX >= 0x02060000
10922   0, /*bf_releasebuffer*/
10923   #endif
10924 };
10925
10926 static PyTypeObject __pyx_type_6ctabix_tabix_copy_iterator = {
10927   PyVarObject_HEAD_INIT(0, 0)
10928   __Pyx_NAMESTR("ctabix.tabix_copy_iterator"), /*tp_name*/
10929   sizeof(struct __pyx_obj_6ctabix_tabix_copy_iterator), /*tp_basicsize*/
10930   0, /*tp_itemsize*/
10931   __pyx_tp_dealloc_6ctabix_tabix_copy_iterator, /*tp_dealloc*/
10932   0, /*tp_print*/
10933   0, /*tp_getattr*/
10934   0, /*tp_setattr*/
10935   #if PY_MAJOR_VERSION < 3
10936   0, /*tp_compare*/
10937   #else
10938   0, /*reserved*/
10939   #endif
10940   0, /*tp_repr*/
10941   &__pyx_tp_as_number_tabix_copy_iterator, /*tp_as_number*/
10942   &__pyx_tp_as_sequence_tabix_copy_iterator, /*tp_as_sequence*/
10943   &__pyx_tp_as_mapping_tabix_copy_iterator, /*tp_as_mapping*/
10944   0, /*tp_hash*/
10945   0, /*tp_call*/
10946   0, /*tp_str*/
10947   0, /*tp_getattro*/
10948   0, /*tp_setattro*/
10949   &__pyx_tp_as_buffer_tabix_copy_iterator, /*tp_as_buffer*/
10950   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
10951   __Pyx_DOCSTR("iterate over ``infile``.\n\n    This iterator is not save. If the :meth:`__next__()` method is called \n    after ``infile`` is closed, the result is undefined (see ``fclose()``).\n\n    The iterator might either raise a StopIteration or segfault.\n    "), /*tp_doc*/
10952   __pyx_tp_traverse_6ctabix_tabix_copy_iterator, /*tp_traverse*/
10953   __pyx_tp_clear_6ctabix_tabix_copy_iterator, /*tp_clear*/
10954   0, /*tp_richcompare*/
10955   0, /*tp_weaklistoffset*/
10956   __pyx_pw_6ctabix_19tabix_copy_iterator_3__iter__, /*tp_iter*/
10957   __pyx_pw_6ctabix_19tabix_copy_iterator_5__next__, /*tp_iternext*/
10958   __pyx_methods_6ctabix_tabix_copy_iterator, /*tp_methods*/
10959   0, /*tp_members*/
10960   0, /*tp_getset*/
10961   0, /*tp_base*/
10962   0, /*tp_dict*/
10963   0, /*tp_descr_get*/
10964   0, /*tp_descr_set*/
10965   0, /*tp_dictoffset*/
10966   0, /*tp_init*/
10967   0, /*tp_alloc*/
10968   __pyx_tp_new_6ctabix_tabix_copy_iterator, /*tp_new*/
10969   0, /*tp_free*/
10970   0, /*tp_is_gc*/
10971   0, /*tp_bases*/
10972   0, /*tp_mro*/
10973   0, /*tp_cache*/
10974   0, /*tp_subclasses*/
10975   0, /*tp_weaklist*/
10976   0, /*tp_del*/
10977   #if PY_VERSION_HEX >= 0x02060000
10978   0, /*tp_version_tag*/
10979   #endif
10980 };
10981
10982 static PyMethodDef __pyx_methods[] = {
10983   {0, 0, 0, 0}
10984 };
10985
10986 #if PY_MAJOR_VERSION >= 3
10987 static struct PyModuleDef __pyx_moduledef = {
10988     PyModuleDef_HEAD_INIT,
10989     __Pyx_NAMESTR("ctabix"),
10990     0, /* m_doc */
10991     -1, /* m_size */
10992     __pyx_methods /* m_methods */,
10993     NULL, /* m_reload */
10994     NULL, /* m_traverse */
10995     NULL, /* m_clear */
10996     NULL /* m_free */
10997 };
10998 #endif
10999
11000 static __Pyx_StringTabEntry __pyx_string_tab[] = {
11001   {&__pyx_kp_u_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 1, 0, 0},
11002   {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
11003   {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
11004   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
11005   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
11006   {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
11007   {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
11008   {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
11009   {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
11010   {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
11011   {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
11012   {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
11013   {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
11014   {&__pyx_kp_u_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 1, 0, 0},
11015   {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
11016   {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
11017   {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
11018   {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
11019   {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
11020   {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
11021   {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
11022   {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
11023   {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
11024   {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
11025   {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
11026   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
11027   {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
11028   {&__pyx_n_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 1},
11029   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
11030   {&__pyx_n_s_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 1, 1},
11031   {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 0},
11032   {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
11033   {&__pyx_kp_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 0},
11034   {&__pyx_n_s_77, __pyx_k_77, sizeof(__pyx_k_77), 0, 0, 1, 1},
11035   {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
11036   {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
11037   {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
11038   {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1},
11039   {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
11040   {&__pyx_n_s__OSError, __pyx_k__OSError, sizeof(__pyx_k__OSError), 0, 0, 1, 1},
11041   {&__pyx_n_s__O_RDONLY, __pyx_k__O_RDONLY, sizeof(__pyx_k__O_RDONLY), 0, 0, 1, 1},
11042   {&__pyx_n_s__PYTHON3, __pyx_k__PYTHON3, sizeof(__pyx_k__PYTHON3), 0, 0, 1, 1},
11043   {&__pyx_n_s__Parser, __pyx_k__Parser, sizeof(__pyx_k__Parser), 0, 0, 1, 1},
11044   {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
11045   {&__pyx_n_s__Tabixfile, __pyx_k__Tabixfile, sizeof(__pyx_k__Tabixfile), 0, 0, 1, 1},
11046   {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
11047   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
11048   {&__pyx_n_s__WINDOW_SIZE, __pyx_k__WINDOW_SIZE, sizeof(__pyx_k__WINDOW_SIZE), 0, 0, 1, 1},
11049   {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
11050   {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
11051   {&__pyx_n_s____iter__, __pyx_k____iter__, sizeof(__pyx_k____iter__), 0, 0, 1, 1},
11052   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
11053   {&__pyx_n_s____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 0, 0, 1, 1},
11054   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
11055   {&__pyx_n_s___isOpen, __pyx_k___isOpen, sizeof(__pyx_k___isOpen), 0, 0, 1, 1},
11056   {&__pyx_n_s___open, __pyx_k___open, sizeof(__pyx_k___open), 0, 0, 1, 1},
11057   {&__pyx_n_s___parseRegion, __pyx_k___parseRegion, sizeof(__pyx_k___parseRegion), 0, 0, 1, 1},
11058   {&__pyx_n_s__asBed, __pyx_k__asBed, sizeof(__pyx_k__asBed), 0, 0, 1, 1},
11059   {&__pyx_n_s__asGTF, __pyx_k__asGTF, sizeof(__pyx_k__asGTF), 0, 0, 1, 1},
11060   {&__pyx_n_s__asTuple, __pyx_k__asTuple, sizeof(__pyx_k__asTuple), 0, 0, 1, 1},
11061   {&__pyx_n_s__asVCF, __pyx_k__asVCF, sizeof(__pyx_k__asVCF), 0, 0, 1, 1},
11062   {&__pyx_n_s__ascii, __pyx_k__ascii, sizeof(__pyx_k__ascii), 0, 0, 1, 1},
11063   {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
11064   {&__pyx_n_s__bed, __pyx_k__bed, sizeof(__pyx_k__bed), 0, 0, 1, 1},
11065   {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
11066   {&__pyx_n_s__buffer_size, __pyx_k__buffer_size, sizeof(__pyx_k__buffer_size), 0, 0, 1, 1},
11067   {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1},
11068   {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
11069   {&__pyx_n_s__closed, __pyx_k__closed, sizeof(__pyx_k__closed), 0, 0, 1, 1},
11070   {&__pyx_n_s__conf, __pyx_k__conf, sizeof(__pyx_k__conf), 0, 0, 1, 1},
11071   {&__pyx_n_s__conf_data, __pyx_k__conf_data, sizeof(__pyx_k__conf_data), 0, 0, 1, 1},
11072   {&__pyx_n_s__cpy, __pyx_k__cpy, sizeof(__pyx_k__cpy), 0, 0, 1, 1},
11073   {&__pyx_n_s__ctabix, __pyx_k__ctabix, sizeof(__pyx_k__ctabix), 0, 0, 1, 1},
11074   {&__pyx_n_s__ctypes, __pyx_k__ctypes, sizeof(__pyx_k__ctypes), 0, 0, 1, 1},
11075   {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
11076   {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
11077   {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
11078   {&__pyx_n_s__end_col, __pyx_k__end_col, sizeof(__pyx_k__end_col), 0, 0, 1, 1},
11079   {&__pyx_n_s__endswith, __pyx_k__endswith, sizeof(__pyx_k__endswith), 0, 0, 1, 1},
11080   {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
11081   {&__pyx_n_s__fd_src, __pyx_k__fd_src, sizeof(__pyx_k__fd_src), 0, 0, 1, 1},
11082   {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
11083   {&__pyx_n_s__filename_in, __pyx_k__filename_in, sizeof(__pyx_k__filename_in), 0, 0, 1, 1},
11084   {&__pyx_n_s__filename_out, __pyx_k__filename_out, sizeof(__pyx_k__filename_out), 0, 0, 1, 1},
11085   {&__pyx_n_s__fn, __pyx_k__fn, sizeof(__pyx_k__fn), 0, 0, 1, 1},
11086   {&__pyx_n_s__force, __pyx_k__force, sizeof(__pyx_k__force), 0, 0, 1, 1},
11087   {&__pyx_n_s__fp, __pyx_k__fp, sizeof(__pyx_k__fp), 0, 0, 1, 1},
11088   {&__pyx_n_s__getdefaultencoding, __pyx_k__getdefaultencoding, sizeof(__pyx_k__getdefaultencoding), 0, 0, 1, 1},
11089   {&__pyx_n_s__gff, __pyx_k__gff, sizeof(__pyx_k__gff), 0, 0, 1, 1},
11090   {&__pyx_n_s__gzip, __pyx_k__gzip, sizeof(__pyx_k__gzip), 0, 0, 1, 1},
11091   {&__pyx_n_s__infile, __pyx_k__infile, sizeof(__pyx_k__infile), 0, 0, 1, 1},
11092   {&__pyx_n_s__io, __pyx_k__io, sizeof(__pyx_k__io), 0, 0, 1, 1},
11093   {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
11094   {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
11095   {&__pyx_n_s__len, __pyx_k__len, sizeof(__pyx_k__len), 0, 0, 1, 1},
11096   {&__pyx_n_s__line, __pyx_k__line, sizeof(__pyx_k__line), 0, 0, 1, 1},
11097   {&__pyx_n_s__meta_char, __pyx_k__meta_char, sizeof(__pyx_k__meta_char), 0, 0, 1, 1},
11098   {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
11099   {&__pyx_n_s__nbytes, __pyx_k__nbytes, sizeof(__pyx_k__nbytes), 0, 0, 1, 1},
11100   {&__pyx_n_s__next, __pyx_k__next, sizeof(__pyx_k__next), 0, 0, 1, 1},
11101   {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1},
11102   {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
11103   {&__pyx_n_s__parser, __pyx_k__parser, sizeof(__pyx_k__parser), 0, 0, 1, 1},
11104   {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
11105   {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
11106   {&__pyx_n_s__present, __pyx_k__present, sizeof(__pyx_k__present), 0, 0, 1, 1},
11107   {&__pyx_n_s__preset, __pyx_k__preset, sizeof(__pyx_k__preset), 0, 0, 1, 1},
11108   {&__pyx_n_s__preset2conf, __pyx_k__preset2conf, sizeof(__pyx_k__preset2conf), 0, 0, 1, 1},
11109   {&__pyx_n_s__psltbl, __pyx_k__psltbl, sizeof(__pyx_k__psltbl), 0, 0, 1, 1},
11110   {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
11111   {&__pyx_n_s__readline, __pyx_k__readline, sizeof(__pyx_k__readline), 0, 0, 1, 1},
11112   {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
11113   {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1},
11114   {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
11115   {&__pyx_n_s__sam, __pyx_k__sam, sizeof(__pyx_k__sam), 0, 0, 1, 1},
11116   {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
11117   {&__pyx_n_s__seq_col, __pyx_k__seq_col, sizeof(__pyx_k__seq_col), 0, 0, 1, 1},
11118   {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
11119   {&__pyx_n_s__start_col, __pyx_k__start_col, sizeof(__pyx_k__start_col), 0, 0, 1, 1},
11120   {&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1},
11121   {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
11122   {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
11123   {&__pyx_n_s__tabix_compress, __pyx_k__tabix_compress, sizeof(__pyx_k__tabix_compress), 0, 0, 1, 1},
11124   {&__pyx_n_s__tabix_index, __pyx_k__tabix_index, sizeof(__pyx_k__tabix_index), 0, 0, 1, 1},
11125   {&__pyx_n_s__tabix_iterator, __pyx_k__tabix_iterator, sizeof(__pyx_k__tabix_iterator), 0, 0, 1, 1},
11126   {&__pyx_n_s__tabixfile, __pyx_k__tabixfile, sizeof(__pyx_k__tabixfile), 0, 0, 1, 1},
11127   {&__pyx_n_s__tempfile, __pyx_k__tempfile, sizeof(__pyx_k__tempfile), 0, 0, 1, 1},
11128   {&__pyx_n_s__tid, __pyx_k__tid, sizeof(__pyx_k__tid), 0, 0, 1, 1},
11129   {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
11130   {&__pyx_n_s__unlink, __pyx_k__unlink, sizeof(__pyx_k__unlink), 0, 0, 1, 1},
11131   {&__pyx_n_s__vcf, __pyx_k__vcf, sizeof(__pyx_k__vcf), 0, 0, 1, 1},
11132   {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1},
11133   {&__pyx_n_s__zerobased, __pyx_k__zerobased, sizeof(__pyx_k__zerobased), 0, 0, 1, 1},
11134   {0, 0, 0, 0, 0, 0, 0}
11135 };
11136 static int __Pyx_InitCachedBuiltins(void) {
11137   __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11138   __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11139   __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11140   __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11141   __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11142   __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11143   __pyx_builtin_ord = __Pyx_GetName(__pyx_b, __pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11144   __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11145   __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11146   return 0;
11147   __pyx_L1_error:;
11148   return -1;
11149 }
11150
11151 static int __Pyx_InitCachedConstants(void) {
11152   __Pyx_RefNannyDeclarations
11153   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
11154
11155   /* "ctabix.pyx":58
11156  *         return s
11157  *     elif PyUnicode_Check(s):
11158  *         return s.encode('ascii')             # <<<<<<<<<<<<<<
11159  *     else:
11160  *         raise TypeError, u"Argument must be string, bytes or unicode."
11161  */
11162   __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11163   __Pyx_GOTREF(__pyx_k_tuple_2);
11164   __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii));
11165   PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_n_s__ascii));
11166   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii));
11167   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
11168
11169   /* "ctabix.pyx":78
11170  *         return s
11171  *     elif PyBytes_Check(s):
11172  *         return s.decode('ascii')             # <<<<<<<<<<<<<<
11173  *     else:
11174  *         # assume unicode
11175  */
11176   __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11177   __Pyx_GOTREF(__pyx_k_tuple_4);
11178   __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii));
11179   PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_n_s__ascii));
11180   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii));
11181   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
11182
11183   /* "ctabix.pyx":112
11184  * 
11185  *         filename_index = filename + ".tbi"
11186  *         self.isremote = filename.startswith( "http:") or filename.startswith( "ftp:" )             # <<<<<<<<<<<<<<
11187  * 
11188  *         # encode all the strings
11189  */
11190   __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11191   __Pyx_GOTREF(__pyx_k_tuple_8);
11192   __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
11193   PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7));
11194   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
11195   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));
11196   __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11197   __Pyx_GOTREF(__pyx_k_tuple_10);
11198   __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
11199   PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_9));
11200   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
11201   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));
11202
11203   /* "ctabix.pyx":117
11204  *         filename = _my_encodeFilename(filename)
11205  *         filename_index = _my_encodeFilename(filename_index)
11206  *         cdef bytes bmode = mode.encode('ascii')             # <<<<<<<<<<<<<<
11207  * 
11208  *         if self._filename != NULL: free(self._filename )
11209  */
11210   __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11211   __Pyx_GOTREF(__pyx_k_tuple_11);
11212   __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii));
11213   PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_n_s__ascii));
11214   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii));
11215   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));
11216
11217   /* "ctabix.pyx":125
11218  *         if mode[0] == 'w':
11219  *             # open file for writing
11220  *             raise NotImplementedError("writing to tabix files not implemented" )             # <<<<<<<<<<<<<<
11221  * 
11222  *         elif mode[0] == "r":
11223  */
11224   __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11225   __Pyx_GOTREF(__pyx_k_tuple_13);
11226   __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
11227   PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_12));
11228   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
11229   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));
11230
11231   /* "ctabix.pyx":212
11232  * 
11233  *         if not self._isOpen():
11234  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
11235  * 
11236  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
11237  */
11238   __pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11239   __Pyx_GOTREF(__pyx_k_tuple_23);
11240   __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
11241   PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_22));
11242   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
11243   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));
11244
11245   /* "ctabix.pyx":235
11246  *         '''filename associated with this object.'''
11247  *         def __get__(self):
11248  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
11249  *             return self._filename
11250  * 
11251  */
11252   __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11253   __Pyx_GOTREF(__pyx_k_tuple_24);
11254   __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
11255   PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_22));
11256   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
11257   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));
11258
11259   /* "ctabix.pyx":302
11260  * 
11261  *         if <void*>self.iterator == NULL:
11262  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
11263  * 
11264  *     def __iter__(self):
11265  */
11266   __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11267   __Pyx_GOTREF(__pyx_k_tuple_26);
11268   __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
11269   PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_kp_s_25));
11270   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
11271   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26));
11272
11273   /* "ctabix.pyx":347
11274  * 
11275  *         if <void*>self.iterator == NULL:
11276  *             raise ValueError("can't open header.\n")             # <<<<<<<<<<<<<<
11277  * 
11278  *     def __iter__(self):
11279  */
11280   __pyx_k_tuple_28 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11281   __Pyx_GOTREF(__pyx_k_tuple_28);
11282   __Pyx_INCREF(((PyObject *)__pyx_kp_s_27));
11283   PyTuple_SET_ITEM(__pyx_k_tuple_28, 0, ((PyObject *)__pyx_kp_s_27));
11284   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_27));
11285   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_28));
11286
11287   /* "ctabix.pyx":539
11288  * 
11289  *         if <void*>self.iterator == NULL:
11290  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
11291  * 
11292  *     def __iter__(self):
11293  */
11294   __pyx_k_tuple_29 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11295   __Pyx_GOTREF(__pyx_k_tuple_29);
11296   __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
11297   PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, ((PyObject *)__pyx_kp_s_25));
11298   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
11299   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29));
11300
11301   /* "ctabix.pyx":590
11302  *     fp = bgzf_open( fn, "w")
11303  *     if fp == NULL:
11304  *         raise IOError( "could not open '%s' for writing" )             # <<<<<<<<<<<<<<
11305  * 
11306  *     fn = _force_bytes(filename_in)
11307  */
11308   __pyx_k_tuple_33 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11309   __Pyx_GOTREF(__pyx_k_tuple_33);
11310   __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
11311   PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, ((PyObject *)__pyx_kp_s_32));
11312   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
11313   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33));
11314
11315   /* "ctabix.pyx":595
11316  *     fd_src = open(fn, O_RDONLY)
11317  *     if fd_src == 0:
11318  *         raise IOError( "could not open '%s' for reading" )             # <<<<<<<<<<<<<<
11319  * 
11320  *     buffer = malloc(WINDOW_SIZE)
11321  */
11322   __pyx_k_tuple_35 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11323   __Pyx_GOTREF(__pyx_k_tuple_35);
11324   __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
11325   PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, ((PyObject *)__pyx_kp_s_34));
11326   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
11327   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35));
11328
11329   /* "ctabix.pyx":605
11330  *         if r < 0:
11331  *             free( buffer )
11332  *             raise OSError("writing failed")             # <<<<<<<<<<<<<<
11333  * 
11334  *     free( buffer )
11335  */
11336   __pyx_k_tuple_37 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11337   __Pyx_GOTREF(__pyx_k_tuple_37);
11338   __Pyx_INCREF(((PyObject *)__pyx_kp_s_36));
11339   PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_kp_s_36));
11340   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_36));
11341   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37));
11342
11343   /* "ctabix.pyx":609
11344  *     free( buffer )
11345  *     r = bgzf_close(fp)
11346  *     if r < 0: raise OSError("writing failed")             # <<<<<<<<<<<<<<
11347  * 
11348  * def tabix_index( filename,
11349  */
11350   __pyx_k_tuple_38 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11351   __Pyx_GOTREF(__pyx_k_tuple_38);
11352   __Pyx_INCREF(((PyObject *)__pyx_kp_s_36));
11353   PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, ((PyObject *)__pyx_kp_s_36));
11354   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_36));
11355   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38));
11356
11357   /* "ctabix.pyx":655
11358  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)
11359  * 
11360  *     if not filename.endswith(".gz"):             # <<<<<<<<<<<<<<
11361  *         tabix_compress( filename, filename + ".gz", force = force )
11362  *         os.unlink( filename )
11363  */
11364   __pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11365   __Pyx_GOTREF(__pyx_k_tuple_44);
11366   __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
11367   PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_kp_s_43));
11368   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
11369   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44));
11370
11371   /* "ctabix.pyx":661
11372  * 
11373  *     if not force and os.path.exists(filename + ".tbi" ):
11374  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )             # <<<<<<<<<<<<<<
11375  * 
11376  *     # columns (1-based)
11377  */
11378   __pyx_k_tuple_46 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11379   __Pyx_GOTREF(__pyx_k_tuple_46);
11380   __Pyx_INCREF(((PyObject *)__pyx_kp_s_45));
11381   PyTuple_SET_ITEM(__pyx_k_tuple_46, 0, ((PyObject *)__pyx_kp_s_45));
11382   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_45));
11383   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46));
11384
11385   /* "ctabix.pyx":719
11386  * 
11387  *         cdef int fd = PyObject_AsFileDescriptor( infile )
11388  *         if fd == -1: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
11389  *         self.infile = fdopen( fd, 'r')
11390  * 
11391  */
11392   __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11393   __Pyx_GOTREF(__pyx_k_tuple_50);
11394   __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
11395   PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, ((PyObject *)__pyx_kp_s_49));
11396   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
11397   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50));
11398
11399   /* "ctabix.pyx":722
11400  *         self.infile = fdopen( fd, 'r')
11401  * 
11402  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
11403  * 
11404  *         self.buffer = <char*>malloc( buffer_size )
11405  */
11406   __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11407   __Pyx_GOTREF(__pyx_k_tuple_51);
11408   __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
11409   PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_s_49));
11410   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
11411   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
11412
11413   /* "ctabix.pyx":780
11414  * 
11415  *         cdef int fd = PyObject_AsFileDescriptor( infile )
11416  *         if fd == -1: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
11417  *         self.infile = fdopen( fd, 'r')
11418  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )
11419  */
11420   __pyx_k_tuple_53 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11421   __Pyx_GOTREF(__pyx_k_tuple_53);
11422   __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
11423   PyTuple_SET_ITEM(__pyx_k_tuple_53, 0, ((PyObject *)__pyx_kp_s_49));
11424   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
11425   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53));
11426
11427   /* "ctabix.pyx":782
11428  *         if fd == -1: raise ValueError( "I/O operation on closed file." )
11429  *         self.infile = fdopen( fd, 'r')
11430  *         if self.infile == NULL: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
11431  *         self.parser = parser
11432  * 
11433  */
11434   __pyx_k_tuple_54 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11435   __Pyx_GOTREF(__pyx_k_tuple_54);
11436   __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
11437   PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, ((PyObject *)__pyx_kp_s_49));
11438   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
11439   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54));
11440
11441   /* "ctabix.pyx":836
11442  * 
11443  *         self.infile = infile
11444  *         if self.infile.closed: raise ValueError( "I/O operation on closed file." )             # <<<<<<<<<<<<<<
11445  *         self.parser = parser
11446  * 
11447  */
11448   __pyx_k_tuple_55 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11449   __Pyx_GOTREF(__pyx_k_tuple_55);
11450   __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
11451   PyTuple_SET_ITEM(__pyx_k_tuple_55, 0, ((PyObject *)__pyx_kp_s_49));
11452   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
11453   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55));
11454
11455   /* "ctabix.pyx":564
11456  *             ti_iter_destroy(self.iterator)
11457  * 
11458  * def tabix_compress( filename_in,             # <<<<<<<<<<<<<<
11459  *                     filename_out,
11460  *                     force = False ):
11461  */
11462   __pyx_k_tuple_61 = PyTuple_New(11); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11463   __Pyx_GOTREF(__pyx_k_tuple_61);
11464   __Pyx_INCREF(((PyObject *)__pyx_n_s__filename_in));
11465   PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__filename_in));
11466   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename_in));
11467   __Pyx_INCREF(((PyObject *)__pyx_n_s__filename_out));
11468   PyTuple_SET_ITEM(__pyx_k_tuple_61, 1, ((PyObject *)__pyx_n_s__filename_out));
11469   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename_out));
11470   __Pyx_INCREF(((PyObject *)__pyx_n_s__force));
11471   PyTuple_SET_ITEM(__pyx_k_tuple_61, 2, ((PyObject *)__pyx_n_s__force));
11472   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__force));
11473   __Pyx_INCREF(((PyObject *)__pyx_n_s__WINDOW_SIZE));
11474   PyTuple_SET_ITEM(__pyx_k_tuple_61, 3, ((PyObject *)__pyx_n_s__WINDOW_SIZE));
11475   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__WINDOW_SIZE));
11476   __Pyx_INCREF(((PyObject *)__pyx_n_s__c));
11477   PyTuple_SET_ITEM(__pyx_k_tuple_61, 4, ((PyObject *)__pyx_n_s__c));
11478   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__c));
11479   __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
11480   PyTuple_SET_ITEM(__pyx_k_tuple_61, 5, ((PyObject *)__pyx_n_s__r));
11481   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
11482   __Pyx_INCREF(((PyObject *)__pyx_n_s__buffer));
11483   PyTuple_SET_ITEM(__pyx_k_tuple_61, 6, ((PyObject *)__pyx_n_s__buffer));
11484   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__buffer));
11485   __Pyx_INCREF(((PyObject *)__pyx_n_s__fp));
11486   PyTuple_SET_ITEM(__pyx_k_tuple_61, 7, ((PyObject *)__pyx_n_s__fp));
11487   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fp));
11488   __Pyx_INCREF(((PyObject *)__pyx_n_s__fd_src));
11489   PyTuple_SET_ITEM(__pyx_k_tuple_61, 8, ((PyObject *)__pyx_n_s__fd_src));
11490   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fd_src));
11491   __Pyx_INCREF(((PyObject *)__pyx_n_s__O_RDONLY));
11492   PyTuple_SET_ITEM(__pyx_k_tuple_61, 9, ((PyObject *)__pyx_n_s__O_RDONLY));
11493   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__O_RDONLY));
11494   __Pyx_INCREF(((PyObject *)__pyx_n_s__fn));
11495   PyTuple_SET_ITEM(__pyx_k_tuple_61, 10, ((PyObject *)__pyx_n_s__fn));
11496   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fn));
11497   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
11498   __pyx_k_codeobj_62 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s__tabix_compress, 564, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11499
11500   /* "ctabix.pyx":611
11501  *     if r < 0: raise OSError("writing failed")
11502  * 
11503  * def tabix_index( filename,             # <<<<<<<<<<<<<<
11504  *                  force = False,
11505  *                  seq_col = None,
11506  */
11507   __pyx_k_tuple_64 = PyTuple_New(12); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11508   __Pyx_GOTREF(__pyx_k_tuple_64);
11509   __Pyx_INCREF(((PyObject *)__pyx_n_s__filename));
11510   PyTuple_SET_ITEM(__pyx_k_tuple_64, 0, ((PyObject *)__pyx_n_s__filename));
11511   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename));
11512   __Pyx_INCREF(((PyObject *)__pyx_n_s__force));
11513   PyTuple_SET_ITEM(__pyx_k_tuple_64, 1, ((PyObject *)__pyx_n_s__force));
11514   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__force));
11515   __Pyx_INCREF(((PyObject *)__pyx_n_s__seq_col));
11516   PyTuple_SET_ITEM(__pyx_k_tuple_64, 2, ((PyObject *)__pyx_n_s__seq_col));
11517   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__seq_col));
11518   __Pyx_INCREF(((PyObject *)__pyx_n_s__start_col));
11519   PyTuple_SET_ITEM(__pyx_k_tuple_64, 3, ((PyObject *)__pyx_n_s__start_col));
11520   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__start_col));
11521   __Pyx_INCREF(((PyObject *)__pyx_n_s__end_col));
11522   PyTuple_SET_ITEM(__pyx_k_tuple_64, 4, ((PyObject *)__pyx_n_s__end_col));
11523   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__end_col));
11524   __Pyx_INCREF(((PyObject *)__pyx_n_s__preset));
11525   PyTuple_SET_ITEM(__pyx_k_tuple_64, 5, ((PyObject *)__pyx_n_s__preset));
11526   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__preset));
11527   __Pyx_INCREF(((PyObject *)__pyx_n_s__meta_char));
11528   PyTuple_SET_ITEM(__pyx_k_tuple_64, 6, ((PyObject *)__pyx_n_s__meta_char));
11529   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__meta_char));
11530   __Pyx_INCREF(((PyObject *)__pyx_n_s__zerobased));
11531   PyTuple_SET_ITEM(__pyx_k_tuple_64, 7, ((PyObject *)__pyx_n_s__zerobased));
11532   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__zerobased));
11533   __Pyx_INCREF(((PyObject *)__pyx_n_s__preset2conf));
11534   PyTuple_SET_ITEM(__pyx_k_tuple_64, 8, ((PyObject *)__pyx_n_s__preset2conf));
11535   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__preset2conf));
11536   __Pyx_INCREF(((PyObject *)__pyx_n_s__conf_data));
11537   PyTuple_SET_ITEM(__pyx_k_tuple_64, 9, ((PyObject *)__pyx_n_s__conf_data));
11538   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__conf_data));
11539   __Pyx_INCREF(((PyObject *)__pyx_n_s__conf));
11540   PyTuple_SET_ITEM(__pyx_k_tuple_64, 10, ((PyObject *)__pyx_n_s__conf));
11541   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__conf));
11542   __Pyx_INCREF(((PyObject *)__pyx_n_s__fn));
11543   PyTuple_SET_ITEM(__pyx_k_tuple_64, 11, ((PyObject *)__pyx_n_s__fn));
11544   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fn));
11545   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64));
11546   __pyx_k_codeobj_65 = (PyObject*)__Pyx_PyCode_New(8, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s__tabix_index, 611, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11547
11548   /* "ctabix.pyx":833
11549  *     Permits the use of file-like objects for example from the gzip module.
11550  *     '''
11551  *     def __init__(self, infile, parser ):             # <<<<<<<<<<<<<<
11552  * 
11553  *         self.infile = infile
11554  */
11555   __pyx_k_tuple_66 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11556   __Pyx_GOTREF(__pyx_k_tuple_66);
11557   __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
11558   PyTuple_SET_ITEM(__pyx_k_tuple_66, 0, ((PyObject *)__pyx_n_s__self));
11559   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
11560   __Pyx_INCREF(((PyObject *)__pyx_n_s__infile));
11561   PyTuple_SET_ITEM(__pyx_k_tuple_66, 1, ((PyObject *)__pyx_n_s__infile));
11562   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__infile));
11563   __Pyx_INCREF(((PyObject *)__pyx_n_s__parser));
11564   PyTuple_SET_ITEM(__pyx_k_tuple_66, 2, ((PyObject *)__pyx_n_s__parser));
11565   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__parser));
11566   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_66));
11567   __pyx_k_codeobj_67 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s____init__, 833, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11568
11569   /* "ctabix.pyx":839
11570  *         self.parser = parser
11571  * 
11572  *     def __iter__(self):             # <<<<<<<<<<<<<<
11573  *         return self
11574  * 
11575  */
11576   __pyx_k_tuple_68 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11577   __Pyx_GOTREF(__pyx_k_tuple_68);
11578   __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
11579   PyTuple_SET_ITEM(__pyx_k_tuple_68, 0, ((PyObject *)__pyx_n_s__self));
11580   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
11581   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_68));
11582   __pyx_k_codeobj_69 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s____iter__, 839, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11583
11584   /* "ctabix.pyx":843
11585  * 
11586  *     # cython version - required for python 3
11587  *     def __next__(self):             # <<<<<<<<<<<<<<
11588  * 
11589  *         cdef char * b, * cpy
11590  */
11591   __pyx_k_tuple_70 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11592   __Pyx_GOTREF(__pyx_k_tuple_70);
11593   __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
11594   PyTuple_SET_ITEM(__pyx_k_tuple_70, 0, ((PyObject *)__pyx_n_s__self));
11595   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
11596   __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
11597   PyTuple_SET_ITEM(__pyx_k_tuple_70, 1, ((PyObject *)__pyx_n_s__b));
11598   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
11599   __Pyx_INCREF(((PyObject *)__pyx_n_s__cpy));
11600   PyTuple_SET_ITEM(__pyx_k_tuple_70, 2, ((PyObject *)__pyx_n_s__cpy));
11601   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cpy));
11602   __Pyx_INCREF(((PyObject *)__pyx_n_s__nbytes));
11603   PyTuple_SET_ITEM(__pyx_k_tuple_70, 3, ((PyObject *)__pyx_n_s__nbytes));
11604   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__nbytes));
11605   __Pyx_INCREF(((PyObject *)__pyx_n_s__line));
11606   PyTuple_SET_ITEM(__pyx_k_tuple_70, 4, ((PyObject *)__pyx_n_s__line));
11607   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line));
11608   __Pyx_INCREF(((PyObject *)__pyx_n_s__s));
11609   PyTuple_SET_ITEM(__pyx_k_tuple_70, 5, ((PyObject *)__pyx_n_s__s));
11610   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s));
11611   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_70));
11612   __pyx_k_codeobj_71 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_70, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s____next__, 843, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11613
11614   /* "ctabix.pyx":877
11615  * 
11616  *     # python version - required for python 2.7
11617  *     def next(self):             # <<<<<<<<<<<<<<
11618  *         return self.__next__()
11619  * 
11620  */
11621   __pyx_k_tuple_72 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11622   __Pyx_GOTREF(__pyx_k_tuple_72);
11623   __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
11624   PyTuple_SET_ITEM(__pyx_k_tuple_72, 0, ((PyObject *)__pyx_n_s__self));
11625   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
11626   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_72));
11627   __pyx_k_codeobj_73 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s__next, 877, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11628
11629   /* "ctabix.pyx":880
11630  *         return self.__next__()
11631  * 
11632  * def tabix_iterator( infile, parser ):             # <<<<<<<<<<<<<<
11633  *     """return an iterator over all entries in a file."""
11634  *     return tabix_generic_iterator( infile, parser )
11635  */
11636   __pyx_k_tuple_75 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11637   __Pyx_GOTREF(__pyx_k_tuple_75);
11638   __Pyx_INCREF(((PyObject *)__pyx_n_s__infile));
11639   PyTuple_SET_ITEM(__pyx_k_tuple_75, 0, ((PyObject *)__pyx_n_s__infile));
11640   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__infile));
11641   __Pyx_INCREF(((PyObject *)__pyx_n_s__parser));
11642   PyTuple_SET_ITEM(__pyx_k_tuple_75, 1, ((PyObject *)__pyx_n_s__parser));
11643   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__parser));
11644   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75));
11645   __pyx_k_codeobj_76 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s__tabix_iterator, 880, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11646   __Pyx_RefNannyFinishContext();
11647   return 0;
11648   __pyx_L1_error:;
11649   __Pyx_RefNannyFinishContext();
11650   return -1;
11651 }
11652
11653 static int __Pyx_InitGlobals(void) {
11654   if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
11655   __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;};
11656   __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;};
11657   __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;};
11658   __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;};
11659   __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;};
11660   __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;};
11661   __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;};
11662   __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;};
11663   __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;};
11664   __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;};
11665   __pyx_int_35 = PyInt_FromLong(35); if (unlikely(!__pyx_int_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
11666   __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;};
11667   return 0;
11668   __pyx_L1_error:;
11669   return -1;
11670 }
11671
11672 #if PY_MAJOR_VERSION < 3
11673 PyMODINIT_FUNC initctabix(void); /*proto*/
11674 PyMODINIT_FUNC initctabix(void)
11675 #else
11676 PyMODINIT_FUNC PyInit_ctabix(void); /*proto*/
11677 PyMODINIT_FUNC PyInit_ctabix(void)
11678 #endif
11679 {
11680   PyObject *__pyx_t_1 = NULL;
11681   PyObject *__pyx_t_2 = NULL;
11682   int __pyx_t_3;
11683   __Pyx_RefNannyDeclarations
11684   #if CYTHON_REFNANNY
11685   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
11686   if (!__Pyx_RefNanny) {
11687       PyErr_Clear();
11688       __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
11689       if (!__Pyx_RefNanny)
11690           Py_FatalError("failed to import 'refnanny' module");
11691   }
11692   #endif
11693   __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ctabix(void)", 0);
11694   if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11695   __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;}
11696   __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;}
11697   #ifdef __Pyx_CyFunction_USED
11698   if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11699   #endif
11700   #ifdef __Pyx_FusedFunction_USED
11701   if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11702   #endif
11703   #ifdef __Pyx_Generator_USED
11704   if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11705   #endif
11706   /*--- Library function declarations ---*/
11707   /*--- Threads initialization code ---*/
11708   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
11709   #ifdef WITH_THREAD /* Python build with threading support? */
11710   PyEval_InitThreads();
11711   #endif
11712   #endif
11713   /*--- Module creation code ---*/
11714   #if PY_MAJOR_VERSION < 3
11715   __pyx_m = Py_InitModule4(__Pyx_NAMESTR("ctabix"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
11716   #else
11717   __pyx_m = PyModule_Create(&__pyx_moduledef);
11718   #endif
11719   if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11720   __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11721   #if CYTHON_COMPILING_IN_PYPY
11722   Py_INCREF(__pyx_b);
11723   #endif
11724   if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
11725   /*--- Initialize various global constants etc. ---*/
11726   if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11727   if (__pyx_module_is_main_ctabix) {
11728     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;};
11729   }
11730   /*--- Builtin init code ---*/
11731   if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11732   /*--- Constants init code ---*/
11733   if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11734   /*--- Global init code ---*/
11735   __pyx_v_6ctabix__FILENAME_ENCODING = ((PyObject*)Py_None); Py_INCREF(Py_None);
11736   /*--- Variable export code ---*/
11737   /*--- Function export code ---*/
11738   /*--- Type init code ---*/
11739   if (PyType_Ready(&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11740   if (__Pyx_SetAttrString(__pyx_m, "Tabixfile", (PyObject *)&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11741   __pyx_ptype_6ctabix_Tabixfile = &__pyx_type_6ctabix_Tabixfile;
11742   if (PyType_Ready(&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11743   #if CYTHON_COMPILING_IN_CPYTHON
11744   {
11745     PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11746     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
11747       __pyx_wrapperbase_6ctabix_13TabixIterator_4__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
11748       __pyx_wrapperbase_6ctabix_13TabixIterator_4__next__.doc = __pyx_doc_6ctabix_13TabixIterator_4__next__;
11749       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_13TabixIterator_4__next__;
11750     }
11751   }
11752   #endif
11753   if (__Pyx_SetAttrString(__pyx_m, "TabixIterator", (PyObject *)&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11754   __pyx_ptype_6ctabix_TabixIterator = &__pyx_type_6ctabix_TabixIterator;
11755   if (PyType_Ready(&__pyx_type_6ctabix_TabixHeaderIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11756   #if CYTHON_COMPILING_IN_CPYTHON
11757   {
11758     PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixHeaderIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11759     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
11760       __pyx_wrapperbase_6ctabix_19TabixHeaderIterator_4__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
11761       __pyx_wrapperbase_6ctabix_19TabixHeaderIterator_4__next__.doc = __pyx_doc_6ctabix_19TabixHeaderIterator_4__next__;
11762       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_19TabixHeaderIterator_4__next__;
11763     }
11764   }
11765   #endif
11766   if (__Pyx_SetAttrString(__pyx_m, "TabixHeaderIterator", (PyObject *)&__pyx_type_6ctabix_TabixHeaderIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11767   __pyx_ptype_6ctabix_TabixHeaderIterator = &__pyx_type_6ctabix_TabixHeaderIterator;
11768   if (PyType_Ready(&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11769   if (__Pyx_SetAttrString(__pyx_m, "Parser", (PyObject *)&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11770   __pyx_ptype_6ctabix_Parser = &__pyx_type_6ctabix_Parser;
11771   __pyx_type_6ctabix_asTuple.tp_base = __pyx_ptype_6ctabix_Parser;
11772   if (PyType_Ready(&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11773   if (__Pyx_SetAttrString(__pyx_m, "asTuple", (PyObject *)&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11774   __pyx_ptype_6ctabix_asTuple = &__pyx_type_6ctabix_asTuple;
11775   __pyx_type_6ctabix_asGTF.tp_base = __pyx_ptype_6ctabix_Parser;
11776   if (PyType_Ready(&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11777   if (__Pyx_SetAttrString(__pyx_m, "asGTF", (PyObject *)&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11778   __pyx_ptype_6ctabix_asGTF = &__pyx_type_6ctabix_asGTF;
11779   __pyx_type_6ctabix_asBed.tp_base = __pyx_ptype_6ctabix_Parser;
11780   if (PyType_Ready(&__pyx_type_6ctabix_asBed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11781   if (__Pyx_SetAttrString(__pyx_m, "asBed", (PyObject *)&__pyx_type_6ctabix_asBed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11782   __pyx_ptype_6ctabix_asBed = &__pyx_type_6ctabix_asBed;
11783   __pyx_type_6ctabix_asVCF.tp_base = __pyx_ptype_6ctabix_Parser;
11784   if (PyType_Ready(&__pyx_type_6ctabix_asVCF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11785   if (__Pyx_SetAttrString(__pyx_m, "asVCF", (PyObject *)&__pyx_type_6ctabix_asVCF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11786   __pyx_ptype_6ctabix_asVCF = &__pyx_type_6ctabix_asVCF;
11787   if (PyType_Ready(&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11788   #if CYTHON_COMPILING_IN_CPYTHON
11789   {
11790     PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11791     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
11792       __pyx_wrapperbase_6ctabix_19TabixIteratorParsed_4__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
11793       __pyx_wrapperbase_6ctabix_19TabixIteratorParsed_4__next__.doc = __pyx_doc_6ctabix_19TabixIteratorParsed_4__next__;
11794       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_19TabixIteratorParsed_4__next__;
11795     }
11796   }
11797   #endif
11798   if (__Pyx_SetAttrString(__pyx_m, "TabixIteratorParsed", (PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11799   __pyx_ptype_6ctabix_TabixIteratorParsed = &__pyx_type_6ctabix_TabixIteratorParsed;
11800   __pyx_vtabptr_6ctabix_tabix_inplace_iterator = &__pyx_vtable_6ctabix_tabix_inplace_iterator;
11801   __pyx_vtable_6ctabix_tabix_inplace_iterator.__pyx___cnext__ = (PyObject *(*)(struct __pyx_obj_6ctabix_tabix_inplace_iterator *))__pyx_f_6ctabix_22tabix_inplace_iterator___cnext__;
11802   if (PyType_Ready(&__pyx_type_6ctabix_tabix_inplace_iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11803   if (__Pyx_SetVtable(__pyx_type_6ctabix_tabix_inplace_iterator.tp_dict, __pyx_vtabptr_6ctabix_tabix_inplace_iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11804   if (__Pyx_SetAttrString(__pyx_m, "tabix_inplace_iterator", (PyObject *)&__pyx_type_6ctabix_tabix_inplace_iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11805   __pyx_ptype_6ctabix_tabix_inplace_iterator = &__pyx_type_6ctabix_tabix_inplace_iterator;
11806   __pyx_vtabptr_6ctabix_tabix_copy_iterator = &__pyx_vtable_6ctabix_tabix_copy_iterator;
11807   __pyx_vtable_6ctabix_tabix_copy_iterator.__pyx___cnext__ = (PyObject *(*)(struct __pyx_obj_6ctabix_tabix_copy_iterator *))__pyx_f_6ctabix_19tabix_copy_iterator___cnext__;
11808   if (PyType_Ready(&__pyx_type_6ctabix_tabix_copy_iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11809   if (__Pyx_SetVtable(__pyx_type_6ctabix_tabix_copy_iterator.tp_dict, __pyx_vtabptr_6ctabix_tabix_copy_iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11810   if (__Pyx_SetAttrString(__pyx_m, "tabix_copy_iterator", (PyObject *)&__pyx_type_6ctabix_tabix_copy_iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11811   __pyx_ptype_6ctabix_tabix_copy_iterator = &__pyx_type_6ctabix_tabix_copy_iterator;
11812   /*--- Type import code ---*/
11813   __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[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11814   __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[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11815   __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[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11816   __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[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11817   __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[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11818   __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[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11819   __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[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11820   __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[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11821   __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[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11822   __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[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11823   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
11824   #if CYTHON_COMPILING_IN_PYPY
11825   sizeof(PyTypeObject),
11826   #else
11827   sizeof(PyHeapTypeObject),
11828   #endif
11829   0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11830   __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[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11831   __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[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11832   /*--- Variable import code ---*/
11833   /*--- Function import code ---*/
11834   /*--- Execution code ---*/
11835
11836   /* "ctabix.pyx":6
11837  * # Helper functions for python 3 compatibility - taken
11838  * # from csamtools.pyx
11839  * import tempfile, os, sys, types, itertools, struct, ctypes, gzip             # <<<<<<<<<<<<<<
11840  * import io
11841  * cimport TabProxies
11842  */
11843   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__tempfile), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11844   __Pyx_GOTREF(__pyx_t_1);
11845   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tempfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11846   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11847   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11848   __Pyx_GOTREF(__pyx_t_1);
11849   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11850   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11851   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11852   __Pyx_GOTREF(__pyx_t_1);
11853   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11854   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11855   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11856   __Pyx_GOTREF(__pyx_t_1);
11857   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11858   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11859   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11860   __Pyx_GOTREF(__pyx_t_1);
11861   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11862   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11863   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11864   __Pyx_GOTREF(__pyx_t_1);
11865   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11866   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11867   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__ctypes), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11868   __Pyx_GOTREF(__pyx_t_1);
11869   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11870   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11871   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__gzip), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11872   __Pyx_GOTREF(__pyx_t_1);
11873   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gzip, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11874   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11875
11876   /* "ctabix.pyx":7
11877  * # from csamtools.pyx
11878  * import tempfile, os, sys, types, itertools, struct, ctypes, gzip
11879  * import io             # <<<<<<<<<<<<<<
11880  * cimport TabProxies
11881  * 
11882  */
11883   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__io), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11884   __Pyx_GOTREF(__pyx_t_1);
11885   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__io, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11886   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11887
11888   /* "ctabix.pyx":14
11889  *     PyObject_AsFileDescriptor
11890  * 
11891  * PYTHON3 = PY_MAJOR_VERSION >= 3             # <<<<<<<<<<<<<<
11892  * 
11893  * # from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
11894  */
11895   __pyx_t_1 = __Pyx_PyBool_FromLong((PY_MAJOR_VERSION >= 3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11896   __Pyx_GOTREF(__pyx_t_1);
11897   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PYTHON3, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11898   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11899
11900   /* "ctabix.pyx":27
11901  * # filename encoding (copied from lxml.etree.pyx)
11902  * cdef str _FILENAME_ENCODING
11903  * _FILENAME_ENCODING = sys.getfilesystemencoding()             # <<<<<<<<<<<<<<
11904  * if _FILENAME_ENCODING is None:
11905  *     _FILENAME_ENCODING = sys.getdefaultencoding()
11906  */
11907   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11908   __Pyx_GOTREF(__pyx_t_1);
11909   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_60); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11910   __Pyx_GOTREF(__pyx_t_2);
11911   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11912   __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11913   __Pyx_GOTREF(__pyx_t_1);
11914   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11915   if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11916   __Pyx_XGOTREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
11917   __Pyx_DECREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
11918   __Pyx_GIVEREF(__pyx_t_1);
11919   __pyx_v_6ctabix__FILENAME_ENCODING = ((PyObject*)__pyx_t_1);
11920   __pyx_t_1 = 0;
11921
11922   /* "ctabix.pyx":28
11923  * cdef str _FILENAME_ENCODING
11924  * _FILENAME_ENCODING = sys.getfilesystemencoding()
11925  * if _FILENAME_ENCODING is None:             # <<<<<<<<<<<<<<
11926  *     _FILENAME_ENCODING = sys.getdefaultencoding()
11927  * if _FILENAME_ENCODING is None:
11928  */
11929   __pyx_t_3 = (__pyx_v_6ctabix__FILENAME_ENCODING == ((PyObject*)Py_None));
11930   if (__pyx_t_3) {
11931
11932     /* "ctabix.pyx":29
11933  * _FILENAME_ENCODING = sys.getfilesystemencoding()
11934  * if _FILENAME_ENCODING is None:
11935  *     _FILENAME_ENCODING = sys.getdefaultencoding()             # <<<<<<<<<<<<<<
11936  * if _FILENAME_ENCODING is None:
11937  *     _FILENAME_ENCODING = 'ascii'
11938  */
11939     __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11940     __Pyx_GOTREF(__pyx_t_1);
11941     __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getdefaultencoding); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11942     __Pyx_GOTREF(__pyx_t_2);
11943     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11944     __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11945     __Pyx_GOTREF(__pyx_t_1);
11946     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11947     if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11948     __Pyx_XGOTREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
11949     __Pyx_DECREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
11950     __Pyx_GIVEREF(__pyx_t_1);
11951     __pyx_v_6ctabix__FILENAME_ENCODING = ((PyObject*)__pyx_t_1);
11952     __pyx_t_1 = 0;
11953     goto __pyx_L2;
11954   }
11955   __pyx_L2:;
11956
11957   /* "ctabix.pyx":30
11958  * if _FILENAME_ENCODING is None:
11959  *     _FILENAME_ENCODING = sys.getdefaultencoding()
11960  * if _FILENAME_ENCODING is None:             # <<<<<<<<<<<<<<
11961  *     _FILENAME_ENCODING = 'ascii'
11962  * 
11963  */
11964   __pyx_t_3 = (__pyx_v_6ctabix__FILENAME_ENCODING == ((PyObject*)Py_None));
11965   if (__pyx_t_3) {
11966
11967     /* "ctabix.pyx":31
11968  *     _FILENAME_ENCODING = sys.getdefaultencoding()
11969  * if _FILENAME_ENCODING is None:
11970  *     _FILENAME_ENCODING = 'ascii'             # <<<<<<<<<<<<<<
11971  * 
11972  * #cdef char* _C_FILENAME_ENCODING
11973  */
11974     __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii));
11975     __Pyx_XGOTREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
11976     __Pyx_DECREF(((PyObject *)__pyx_v_6ctabix__FILENAME_ENCODING));
11977     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii));
11978     __pyx_v_6ctabix__FILENAME_ENCODING = __pyx_n_s__ascii;
11979     goto __pyx_L3;
11980   }
11981   __pyx_L3:;
11982
11983   /* "ctabix.pyx":566
11984  * def tabix_compress( filename_in,
11985  *                     filename_out,
11986  *                     force = False ):             # <<<<<<<<<<<<<<
11987  *     '''
11988  *     compress *filename_in* writing the output to *filename_out*.
11989  */
11990   __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11991   __Pyx_GOTREF(__pyx_t_1);
11992   __pyx_k_30 = __pyx_t_1;
11993   __Pyx_GIVEREF(__pyx_t_1);
11994   __pyx_t_1 = 0;
11995
11996   /* "ctabix.pyx":564
11997  *             ti_iter_destroy(self.iterator)
11998  * 
11999  * def tabix_compress( filename_in,             # <<<<<<<<<<<<<<
12000  *                     filename_out,
12001  *                     force = False ):
12002  */
12003   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6ctabix_1tabix_compress, NULL, __pyx_n_s__ctabix); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12004   __Pyx_GOTREF(__pyx_t_1);
12005   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tabix_compress, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12006   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12007
12008   /* "ctabix.pyx":612
12009  * 
12010  * def tabix_index( filename,
12011  *                  force = False,             # <<<<<<<<<<<<<<
12012  *                  seq_col = None,
12013  *                  start_col = None,
12014  */
12015   __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12016   __Pyx_GOTREF(__pyx_t_1);
12017   __pyx_k_39 = __pyx_t_1;
12018   __Pyx_GIVEREF(__pyx_t_1);
12019   __pyx_t_1 = 0;
12020
12021   /* "ctabix.pyx":618
12022  *                  preset = None,
12023  *                  meta_char = "#",
12024  *                  zerobased = False,             # <<<<<<<<<<<<<<
12025  *                 ):
12026  *     '''
12027  */
12028   __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12029   __Pyx_GOTREF(__pyx_t_1);
12030   __pyx_k_41 = __pyx_t_1;
12031   __Pyx_GIVEREF(__pyx_t_1);
12032   __pyx_t_1 = 0;
12033
12034   /* "ctabix.pyx":611
12035  *     if r < 0: raise OSError("writing failed")
12036  * 
12037  * def tabix_index( filename,             # <<<<<<<<<<<<<<
12038  *                  force = False,
12039  *                  seq_col = None,
12040  */
12041   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6ctabix_3tabix_index, NULL, __pyx_n_s__ctabix); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12042   __Pyx_GOTREF(__pyx_t_1);
12043   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tabix_index, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12044   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12045
12046   /* "ctabix.pyx":828
12047  *         return self.__cnext__()
12048  * 
12049  * class tabix_generic_iterator:             # <<<<<<<<<<<<<<
12050  *     '''iterate over ``infile``.
12051  * 
12052  */
12053   __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12054   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
12055
12056   /* "ctabix.pyx":833
12057  *     Permits the use of file-like objects for example from the gzip module.
12058  *     '''
12059  *     def __init__(self, infile, parser ):             # <<<<<<<<<<<<<<
12060  * 
12061  *         self.infile = infile
12062  */
12063   __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6ctabix_22tabix_generic_iterator_1__init__, 0, NULL, __pyx_n_s__ctabix, ((PyObject *)__pyx_k_codeobj_67)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12064   __Pyx_GOTREF(__pyx_t_2);
12065   if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12066   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12067
12068   /* "ctabix.pyx":839
12069  *         self.parser = parser
12070  * 
12071  *     def __iter__(self):             # <<<<<<<<<<<<<<
12072  *         return self
12073  * 
12074  */
12075   __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6ctabix_22tabix_generic_iterator_3__iter__, 0, NULL, __pyx_n_s__ctabix, ((PyObject *)__pyx_k_codeobj_69)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12076   __Pyx_GOTREF(__pyx_t_2);
12077   if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____iter__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12078   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12079
12080   /* "ctabix.pyx":843
12081  * 
12082  *     # cython version - required for python 3
12083  *     def __next__(self):             # <<<<<<<<<<<<<<
12084  * 
12085  *         cdef char * b, * cpy
12086  */
12087   __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6ctabix_22tabix_generic_iterator_5__next__, 0, NULL, __pyx_n_s__ctabix, ((PyObject *)__pyx_k_codeobj_71)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12088   __Pyx_GOTREF(__pyx_t_2);
12089   if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____next__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12090   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12091
12092   /* "ctabix.pyx":877
12093  * 
12094  *     # python version - required for python 2.7
12095  *     def next(self):             # <<<<<<<<<<<<<<
12096  *         return self.__next__()
12097  * 
12098  */
12099   __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6ctabix_22tabix_generic_iterator_7next, 0, NULL, __pyx_n_s__ctabix, ((PyObject *)__pyx_k_codeobj_73)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12100   __Pyx_GOTREF(__pyx_t_2);
12101   if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__next, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12102   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12103
12104   /* "ctabix.pyx":828
12105  *         return self.__cnext__()
12106  * 
12107  * class tabix_generic_iterator:             # <<<<<<<<<<<<<<
12108  *     '''iterate over ``infile``.
12109  * 
12110  */
12111   if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_74)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12112   __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s_56, __pyx_n_s__ctabix); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12113   __Pyx_GOTREF(__pyx_t_2);
12114   if (PyObject_SetAttr(__pyx_m, __pyx_n_s_56, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12115   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12116   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
12117
12118   /* "ctabix.pyx":880
12119  *         return self.__next__()
12120  * 
12121  * def tabix_iterator( infile, parser ):             # <<<<<<<<<<<<<<
12122  *     """return an iterator over all entries in a file."""
12123  *     return tabix_generic_iterator( infile, parser )
12124  */
12125   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6ctabix_5tabix_iterator, NULL, __pyx_n_s__ctabix); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12126   __Pyx_GOTREF(__pyx_t_1);
12127   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tabix_iterator, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12128   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12129
12130   /* "ctabix.pyx":896
12131  * #            return tabix_generic_iterator( infile, parser )
12132  * 
12133  * __all__ = ["tabix_index",             # <<<<<<<<<<<<<<
12134  *            "tabix_compress",
12135  *            "Tabixfile",
12136  */
12137   __pyx_t_1 = PyList_New(9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12138   __Pyx_GOTREF(__pyx_t_1);
12139   __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_index));
12140   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tabix_index));
12141   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_index));
12142   __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_compress));
12143   PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__tabix_compress));
12144   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_compress));
12145   __Pyx_INCREF(((PyObject *)__pyx_n_s__Tabixfile));
12146   PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__Tabixfile));
12147   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Tabixfile));
12148   __Pyx_INCREF(((PyObject *)__pyx_n_s__asTuple));
12149   PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__asTuple));
12150   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asTuple));
12151   __Pyx_INCREF(((PyObject *)__pyx_n_s__asGTF));
12152   PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__asGTF));
12153   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asGTF));
12154   __Pyx_INCREF(((PyObject *)__pyx_n_s__asVCF));
12155   PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__asVCF));
12156   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asVCF));
12157   __Pyx_INCREF(((PyObject *)__pyx_n_s__asBed));
12158   PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__asBed));
12159   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asBed));
12160   __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_iterator));
12161   PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__tabix_iterator));
12162   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_iterator));
12163   __Pyx_INCREF(((PyObject *)__pyx_n_s_77));
12164   PyList_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s_77));
12165   __Pyx_GIVEREF(((PyObject *)__pyx_n_s_77));
12166   if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12167   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
12168
12169   /* "ctabix.pyx":1
12170  * # cython: embedsignature=True             # <<<<<<<<<<<<<<
12171  * # adds doc-strings for sphinx
12172  * 
12173  */
12174   __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;}
12175   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
12176   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;}
12177   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
12178   goto __pyx_L0;
12179   __pyx_L1_error:;
12180   __Pyx_XDECREF(__pyx_t_1);
12181   __Pyx_XDECREF(__pyx_t_2);
12182   if (__pyx_m) {
12183     __Pyx_AddTraceback("init ctabix", __pyx_clineno, __pyx_lineno, __pyx_filename);
12184     Py_DECREF(__pyx_m); __pyx_m = 0;
12185   } else if (!PyErr_Occurred()) {
12186     PyErr_SetString(PyExc_ImportError, "init ctabix");
12187   }
12188   __pyx_L0:;
12189   __Pyx_RefNannyFinishContext();
12190   #if PY_MAJOR_VERSION < 3
12191   return;
12192   #else
12193   return __pyx_m;
12194   #endif
12195 }
12196
12197 /* Runtime support code */
12198 #if CYTHON_REFNANNY
12199 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
12200     PyObject *m = NULL, *p = NULL;
12201     void *r = NULL;
12202     m = PyImport_ImportModule((char *)modname);
12203     if (!m) goto end;
12204     p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
12205     if (!p) goto end;
12206     r = PyLong_AsVoidPtr(p);
12207 end:
12208     Py_XDECREF(p);
12209     Py_XDECREF(m);
12210     return (__Pyx_RefNannyAPIStruct *)r;
12211 }
12212 #endif /* CYTHON_REFNANNY */
12213
12214 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
12215     PyObject *result;
12216     result = PyObject_GetAttr(dict, name);
12217     if (!result) {
12218         if (dict != __pyx_b) {
12219             PyErr_Clear();
12220             result = PyObject_GetAttr(__pyx_b, name);
12221         }
12222         if (!result) {
12223             PyErr_SetObject(PyExc_NameError, name);
12224         }
12225     }
12226     return result;
12227 }
12228
12229 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
12230          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
12231          const char* encoding, const char* errors,
12232          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
12233     Py_ssize_t length;
12234     if (unlikely((start < 0) | (stop < 0))) {
12235         length = strlen(cstring);
12236         if (start < 0) {
12237             start += length;
12238             if (start < 0)
12239                 start = 0;
12240         }
12241         if (stop < 0)
12242             stop += length;
12243     }
12244     length = stop - start;
12245     if (unlikely(length <= 0))
12246         return PyUnicode_FromUnicode(NULL, 0);
12247     cstring += start;
12248     if (decode_func) {
12249         return decode_func(cstring, length, errors);
12250     } else {
12251         return PyUnicode_Decode(cstring, length, encoding, errors);
12252     }
12253 }
12254
12255 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
12256 #if CYTHON_COMPILING_IN_CPYTHON
12257     PyObject *tmp_type, *tmp_value, *tmp_tb;
12258     PyThreadState *tstate = PyThreadState_GET();
12259     tmp_type = tstate->curexc_type;
12260     tmp_value = tstate->curexc_value;
12261     tmp_tb = tstate->curexc_traceback;
12262     tstate->curexc_type = type;
12263     tstate->curexc_value = value;
12264     tstate->curexc_traceback = tb;
12265     Py_XDECREF(tmp_type);
12266     Py_XDECREF(tmp_value);
12267     Py_XDECREF(tmp_tb);
12268 #else
12269     PyErr_Restore(type, value, tb);
12270 #endif
12271 }
12272 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
12273 #if CYTHON_COMPILING_IN_CPYTHON
12274     PyThreadState *tstate = PyThreadState_GET();
12275     *type = tstate->curexc_type;
12276     *value = tstate->curexc_value;
12277     *tb = tstate->curexc_traceback;
12278     tstate->curexc_type = 0;
12279     tstate->curexc_value = 0;
12280     tstate->curexc_traceback = 0;
12281 #else
12282     PyErr_Fetch(type, value, tb);
12283 #endif
12284 }
12285
12286 #if PY_MAJOR_VERSION < 3
12287 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
12288                         CYTHON_UNUSED PyObject *cause) {
12289     Py_XINCREF(type);
12290     if (!value || value == Py_None)
12291         value = NULL;
12292     else
12293         Py_INCREF(value);
12294     if (!tb || tb == Py_None)
12295         tb = NULL;
12296     else {
12297         Py_INCREF(tb);
12298         if (!PyTraceBack_Check(tb)) {
12299             PyErr_SetString(PyExc_TypeError,
12300                 "raise: arg 3 must be a traceback or None");
12301             goto raise_error;
12302         }
12303     }
12304     #if PY_VERSION_HEX < 0x02050000
12305     if (PyClass_Check(type)) {
12306     #else
12307     if (PyType_Check(type)) {
12308     #endif
12309 #if CYTHON_COMPILING_IN_PYPY
12310         if (!value) {
12311             Py_INCREF(Py_None);
12312             value = Py_None;
12313         }
12314 #endif
12315         PyErr_NormalizeException(&type, &value, &tb);
12316     } else {
12317         if (value) {
12318             PyErr_SetString(PyExc_TypeError,
12319                 "instance exception may not have a separate value");
12320             goto raise_error;
12321         }
12322         value = type;
12323         #if PY_VERSION_HEX < 0x02050000
12324             if (PyInstance_Check(type)) {
12325                 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
12326                 Py_INCREF(type);
12327             }
12328             else {
12329                 type = 0;
12330                 PyErr_SetString(PyExc_TypeError,
12331                     "raise: exception must be an old-style class or instance");
12332                 goto raise_error;
12333             }
12334         #else
12335             type = (PyObject*) Py_TYPE(type);
12336             Py_INCREF(type);
12337             if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
12338                 PyErr_SetString(PyExc_TypeError,
12339                     "raise: exception class must be a subclass of BaseException");
12340                 goto raise_error;
12341             }
12342         #endif
12343     }
12344     __Pyx_ErrRestore(type, value, tb);
12345     return;
12346 raise_error:
12347     Py_XDECREF(value);
12348     Py_XDECREF(type);
12349     Py_XDECREF(tb);
12350     return;
12351 }
12352 #else /* Python 3+ */
12353 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
12354     PyObject* owned_instance = NULL;
12355     if (tb == Py_None) {
12356         tb = 0;
12357     } else if (tb && !PyTraceBack_Check(tb)) {
12358         PyErr_SetString(PyExc_TypeError,
12359             "raise: arg 3 must be a traceback or None");
12360         goto bad;
12361     }
12362     if (value == Py_None)
12363         value = 0;
12364     if (PyExceptionInstance_Check(type)) {
12365         if (value) {
12366             PyErr_SetString(PyExc_TypeError,
12367                 "instance exception may not have a separate value");
12368             goto bad;
12369         }
12370         value = type;
12371         type = (PyObject*) Py_TYPE(value);
12372     } else if (PyExceptionClass_Check(type)) {
12373         PyObject *args;
12374         if (!value)
12375             args = PyTuple_New(0);
12376         else if (PyTuple_Check(value)) {
12377             Py_INCREF(value);
12378             args = value;
12379         }
12380         else
12381             args = PyTuple_Pack(1, value);
12382         if (!args)
12383             goto bad;
12384         owned_instance = PyEval_CallObject(type, args);
12385         Py_DECREF(args);
12386         if (!owned_instance)
12387             goto bad;
12388         value = owned_instance;
12389         if (!PyExceptionInstance_Check(value)) {
12390             PyErr_Format(PyExc_TypeError,
12391                          "calling %R should have returned an instance of "
12392                          "BaseException, not %R",
12393                          type, Py_TYPE(value));
12394             goto bad;
12395         }
12396     } else {
12397         PyErr_SetString(PyExc_TypeError,
12398             "raise: exception class must be a subclass of BaseException");
12399         goto bad;
12400     }
12401     if (cause && cause != Py_None) {
12402         PyObject *fixed_cause;
12403         if (PyExceptionClass_Check(cause)) {
12404             fixed_cause = PyObject_CallObject(cause, NULL);
12405             if (fixed_cause == NULL)
12406                 goto bad;
12407         }
12408         else if (PyExceptionInstance_Check(cause)) {
12409             fixed_cause = cause;
12410             Py_INCREF(fixed_cause);
12411         }
12412         else {
12413             PyErr_SetString(PyExc_TypeError,
12414                             "exception causes must derive from "
12415                             "BaseException");
12416             goto bad;
12417         }
12418         PyException_SetCause(value, fixed_cause);
12419     }
12420     PyErr_SetObject(type, value);
12421     if (tb) {
12422         PyThreadState *tstate = PyThreadState_GET();
12423         PyObject* tmp_tb = tstate->curexc_traceback;
12424         if (tb != tmp_tb) {
12425             Py_INCREF(tb);
12426             tstate->curexc_traceback = tb;
12427             Py_XDECREF(tmp_tb);
12428         }
12429     }
12430 bad:
12431     Py_XDECREF(owned_instance);
12432     return;
12433 }
12434 #endif
12435
12436 static void __Pyx_RaiseDoubleKeywordsError(
12437     const char* func_name,
12438     PyObject* kw_name)
12439 {
12440     PyErr_Format(PyExc_TypeError,
12441         #if PY_MAJOR_VERSION >= 3
12442         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
12443         #else
12444         "%s() got multiple values for keyword argument '%s'", func_name,
12445         PyString_AsString(kw_name));
12446         #endif
12447 }
12448
12449 static int __Pyx_ParseOptionalKeywords(
12450     PyObject *kwds,
12451     PyObject **argnames[],
12452     PyObject *kwds2,
12453     PyObject *values[],
12454     Py_ssize_t num_pos_args,
12455     const char* function_name)
12456 {
12457     PyObject *key = 0, *value = 0;
12458     Py_ssize_t pos = 0;
12459     PyObject*** name;
12460     PyObject*** first_kw_arg = argnames + num_pos_args;
12461     while (PyDict_Next(kwds, &pos, &key, &value)) {
12462         name = first_kw_arg;
12463         while (*name && (**name != key)) name++;
12464         if (*name) {
12465             values[name-argnames] = value;
12466             continue;
12467         }
12468         name = first_kw_arg;
12469         #if PY_MAJOR_VERSION < 3
12470         if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
12471             while (*name) {
12472                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
12473                         && _PyString_Eq(**name, key)) {
12474                     values[name-argnames] = value;
12475                     break;
12476                 }
12477                 name++;
12478             }
12479             if (*name) continue;
12480             else {
12481                 PyObject*** argname = argnames;
12482                 while (argname != first_kw_arg) {
12483                     if ((**argname == key) || (
12484                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
12485                              && _PyString_Eq(**argname, key))) {
12486                         goto arg_passed_twice;
12487                     }
12488                     argname++;
12489                 }
12490             }
12491         } else
12492         #endif
12493         if (likely(PyUnicode_Check(key))) {
12494             while (*name) {
12495                 int cmp = (**name == key) ? 0 :
12496                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
12497                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
12498                 #endif
12499                     PyUnicode_Compare(**name, key);
12500                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
12501                 if (cmp == 0) {
12502                     values[name-argnames] = value;
12503                     break;
12504                 }
12505                 name++;
12506             }
12507             if (*name) continue;
12508             else {
12509                 PyObject*** argname = argnames;
12510                 while (argname != first_kw_arg) {
12511                     int cmp = (**argname == key) ? 0 :
12512                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
12513                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
12514                     #endif
12515                         PyUnicode_Compare(**argname, key);
12516                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
12517                     if (cmp == 0) goto arg_passed_twice;
12518                     argname++;
12519                 }
12520             }
12521         } else
12522             goto invalid_keyword_type;
12523         if (kwds2) {
12524             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
12525         } else {
12526             goto invalid_keyword;
12527         }
12528     }
12529     return 0;
12530 arg_passed_twice:
12531     __Pyx_RaiseDoubleKeywordsError(function_name, key);
12532     goto bad;
12533 invalid_keyword_type:
12534     PyErr_Format(PyExc_TypeError,
12535         "%s() keywords must be strings", function_name);
12536     goto bad;
12537 invalid_keyword:
12538     PyErr_Format(PyExc_TypeError,
12539     #if PY_MAJOR_VERSION < 3
12540         "%s() got an unexpected keyword argument '%s'",
12541         function_name, PyString_AsString(key));
12542     #else
12543         "%s() got an unexpected keyword argument '%U'",
12544         function_name, key);
12545     #endif
12546 bad:
12547     return -1;
12548 }
12549
12550 static void __Pyx_RaiseArgtupleInvalid(
12551     const char* func_name,
12552     int exact,
12553     Py_ssize_t num_min,
12554     Py_ssize_t num_max,
12555     Py_ssize_t num_found)
12556 {
12557     Py_ssize_t num_expected;
12558     const char *more_or_less;
12559     if (num_found < num_min) {
12560         num_expected = num_min;
12561         more_or_less = "at least";
12562     } else {
12563         num_expected = num_max;
12564         more_or_less = "at most";
12565     }
12566     if (exact) {
12567         more_or_less = "exactly";
12568     }
12569     PyErr_Format(PyExc_TypeError,
12570                  "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
12571                  func_name, more_or_less, num_expected,
12572                  (num_expected == 1) ? "" : "s", num_found);
12573 }
12574
12575 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
12576     PyErr_Format(PyExc_ValueError,
12577                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
12578 }
12579
12580 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
12581     PyErr_Format(PyExc_ValueError,
12582                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack",
12583                  index, (index == 1) ? "" : "s");
12584 }
12585
12586 static CYTHON_INLINE int __Pyx_IterFinish(void) {
12587 #if CYTHON_COMPILING_IN_CPYTHON
12588     PyThreadState *tstate = PyThreadState_GET();
12589     PyObject* exc_type = tstate->curexc_type;
12590     if (unlikely(exc_type)) {
12591         if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
12592             PyObject *exc_value, *exc_tb;
12593             exc_value = tstate->curexc_value;
12594             exc_tb = tstate->curexc_traceback;
12595             tstate->curexc_type = 0;
12596             tstate->curexc_value = 0;
12597             tstate->curexc_traceback = 0;
12598             Py_DECREF(exc_type);
12599             Py_XDECREF(exc_value);
12600             Py_XDECREF(exc_tb);
12601             return 0;
12602         } else {
12603             return -1;
12604         }
12605     }
12606     return 0;
12607 #else
12608     if (unlikely(PyErr_Occurred())) {
12609         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
12610             PyErr_Clear();
12611             return 0;
12612         } else {
12613             return -1;
12614         }
12615     }
12616     return 0;
12617 #endif
12618 }
12619
12620 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
12621     if (unlikely(retval)) {
12622         Py_DECREF(retval);
12623         __Pyx_RaiseTooManyValuesError(expected);
12624         return -1;
12625     } else {
12626         return __Pyx_IterFinish();
12627     }
12628     return 0;
12629 }
12630
12631 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
12632     const char *name, int exact)
12633 {
12634     if (!type) {
12635         PyErr_Format(PyExc_SystemError, "Missing type object");
12636         return 0;
12637     }
12638     if (none_allowed && obj == Py_None) return 1;
12639     else if (exact) {
12640         if (Py_TYPE(obj) == type) return 1;
12641     }
12642     else {
12643         if (PyObject_TypeCheck(obj, type)) return 1;
12644     }
12645     PyErr_Format(PyExc_TypeError,
12646         "Argument '%s' has incorrect type (expected %s, got %s)",
12647         name, type->tp_name, Py_TYPE(obj)->tp_name);
12648     return 0;
12649 }
12650
12651 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
12652     PyObject *local_type, *local_value, *local_tb;
12653 #if CYTHON_COMPILING_IN_CPYTHON
12654     PyObject *tmp_type, *tmp_value, *tmp_tb;
12655     PyThreadState *tstate = PyThreadState_GET();
12656     local_type = tstate->curexc_type;
12657     local_value = tstate->curexc_value;
12658     local_tb = tstate->curexc_traceback;
12659     tstate->curexc_type = 0;
12660     tstate->curexc_value = 0;
12661     tstate->curexc_traceback = 0;
12662 #else
12663     PyErr_Fetch(&local_type, &local_value, &local_tb);
12664 #endif
12665     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
12666 #if CYTHON_COMPILING_IN_CPYTHON
12667     if (unlikely(tstate->curexc_type))
12668 #else
12669     if (unlikely(PyErr_Occurred()))
12670 #endif
12671         goto bad;
12672     #if PY_MAJOR_VERSION >= 3
12673     if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
12674         goto bad;
12675     #endif
12676     Py_INCREF(local_type);
12677     Py_INCREF(local_value);
12678     Py_INCREF(local_tb);
12679     *type = local_type;
12680     *value = local_value;
12681     *tb = local_tb;
12682 #if CYTHON_COMPILING_IN_CPYTHON
12683     tmp_type = tstate->exc_type;
12684     tmp_value = tstate->exc_value;
12685     tmp_tb = tstate->exc_traceback;
12686     tstate->exc_type = local_type;
12687     tstate->exc_value = local_value;
12688     tstate->exc_traceback = local_tb;
12689     /* Make sure tstate is in a consistent state when we XDECREF
12690        these objects (DECREF may run arbitrary code). */
12691     Py_XDECREF(tmp_type);
12692     Py_XDECREF(tmp_value);
12693     Py_XDECREF(tmp_tb);
12694 #else
12695     PyErr_SetExcInfo(local_type, local_value, local_tb);
12696 #endif
12697     return 0;
12698 bad:
12699     *type = 0;
12700     *value = 0;
12701     *tb = 0;
12702     Py_XDECREF(local_type);
12703     Py_XDECREF(local_value);
12704     Py_XDECREF(local_tb);
12705     return -1;
12706 }
12707
12708 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
12709 #if CYTHON_COMPILING_IN_CPYTHON
12710     PyThreadState *tstate = PyThreadState_GET();
12711     *type = tstate->exc_type;
12712     *value = tstate->exc_value;
12713     *tb = tstate->exc_traceback;
12714     Py_XINCREF(*type);
12715     Py_XINCREF(*value);
12716     Py_XINCREF(*tb);
12717 #else
12718     PyErr_GetExcInfo(type, value, tb);
12719 #endif
12720 }
12721 static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
12722 #if CYTHON_COMPILING_IN_CPYTHON
12723     PyObject *tmp_type, *tmp_value, *tmp_tb;
12724     PyThreadState *tstate = PyThreadState_GET();
12725     tmp_type = tstate->exc_type;
12726     tmp_value = tstate->exc_value;
12727     tmp_tb = tstate->exc_traceback;
12728     tstate->exc_type = type;
12729     tstate->exc_value = value;
12730     tstate->exc_traceback = tb;
12731     Py_XDECREF(tmp_type);
12732     Py_XDECREF(tmp_value);
12733     Py_XDECREF(tmp_tb);
12734 #else
12735     PyErr_SetExcInfo(type, value, tb);
12736 #endif
12737 }
12738
12739 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
12740     PyObject *py_import = 0;
12741     PyObject *empty_list = 0;
12742     PyObject *module = 0;
12743     PyObject *global_dict = 0;
12744     PyObject *empty_dict = 0;
12745     PyObject *list;
12746     py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
12747     if (!py_import)
12748         goto bad;
12749     if (from_list)
12750         list = from_list;
12751     else {
12752         empty_list = PyList_New(0);
12753         if (!empty_list)
12754             goto bad;
12755         list = empty_list;
12756     }
12757     global_dict = PyModule_GetDict(__pyx_m);
12758     if (!global_dict)
12759         goto bad;
12760     empty_dict = PyDict_New();
12761     if (!empty_dict)
12762         goto bad;
12763     #if PY_VERSION_HEX >= 0x02050000
12764     {
12765         #if PY_MAJOR_VERSION >= 3
12766         if (level == -1) {
12767             if (strchr(__Pyx_MODULE_NAME, '.')) {
12768                 /* try package relative import first */
12769                 PyObject *py_level = PyInt_FromLong(1);
12770                 if (!py_level)
12771                     goto bad;
12772                 module = PyObject_CallFunctionObjArgs(py_import,
12773                     name, global_dict, empty_dict, list, py_level, NULL);
12774                 Py_DECREF(py_level);
12775                 if (!module) {
12776                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
12777                         goto bad;
12778                     PyErr_Clear();
12779                 }
12780             }
12781             level = 0; /* try absolute import on failure */
12782         }
12783         #endif
12784         if (!module) {
12785             PyObject *py_level = PyInt_FromLong(level);
12786             if (!py_level)
12787                 goto bad;
12788             module = PyObject_CallFunctionObjArgs(py_import,
12789                 name, global_dict, empty_dict, list, py_level, NULL);
12790             Py_DECREF(py_level);
12791         }
12792     }
12793     #else
12794     if (level>0) {
12795         PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
12796         goto bad;
12797     }
12798     module = PyObject_CallFunctionObjArgs(py_import,
12799         name, global_dict, empty_dict, list, NULL);
12800     #endif
12801 bad:
12802     Py_XDECREF(empty_list);
12803     Py_XDECREF(py_import);
12804     Py_XDECREF(empty_dict);
12805     return module;
12806 }
12807
12808 static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
12809     PyObject *metaclass;
12810 #if PY_MAJOR_VERSION < 3
12811     if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
12812         PyObject *base = PyTuple_GET_ITEM(bases, 0);
12813         metaclass = PyObject_GetAttrString(base, (char *)"__class__");
12814         if (!metaclass) {
12815             PyErr_Clear();
12816             metaclass = (PyObject*) Py_TYPE(base);
12817         }
12818     } else {
12819         metaclass = (PyObject *) &PyClass_Type;
12820     }
12821 #else
12822     if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
12823         PyObject *base = PyTuple_GET_ITEM(bases, 0);
12824         metaclass = (PyObject*) Py_TYPE(base);
12825     } else {
12826         metaclass = (PyObject *) &PyType_Type;
12827     }
12828 #endif
12829     Py_INCREF(metaclass);
12830     return metaclass;
12831 }
12832
12833 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
12834                                    PyObject *modname) {
12835     PyObject *result;
12836     PyObject *metaclass;
12837     if (PyDict_SetItemString(dict, "__module__", modname) < 0)
12838         return NULL;
12839     metaclass = PyDict_GetItemString(dict, "__metaclass__");
12840     if (metaclass) {
12841         Py_INCREF(metaclass);
12842     } else {
12843         metaclass = __Pyx_FindPy2Metaclass(bases);
12844     }
12845     result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
12846     Py_DECREF(metaclass);
12847     return result;
12848 }
12849
12850 static PyObject *
12851 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
12852 {
12853     if (op->func_doc == NULL && op->func.m_ml->ml_doc) {
12854 #if PY_MAJOR_VERSION >= 3
12855         op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
12856 #else
12857         op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
12858 #endif
12859     }
12860     if (op->func_doc == 0) {
12861         Py_INCREF(Py_None);
12862         return Py_None;
12863     }
12864     Py_INCREF(op->func_doc);
12865     return op->func_doc;
12866 }
12867 static int
12868 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
12869 {
12870     PyObject *tmp = op->func_doc;
12871     if (value == NULL)
12872         op->func_doc = Py_None; /* Mark as deleted */
12873     else
12874         op->func_doc = value;
12875     Py_INCREF(op->func_doc);
12876     Py_XDECREF(tmp);
12877     return 0;
12878 }
12879 static PyObject *
12880 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
12881 {
12882     if (op->func_name == NULL) {
12883 #if PY_MAJOR_VERSION >= 3
12884         op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
12885 #else
12886         op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
12887 #endif
12888     }
12889     Py_INCREF(op->func_name);
12890     return op->func_name;
12891 }
12892 static int
12893 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
12894 {
12895     PyObject *tmp;
12896 #if PY_MAJOR_VERSION >= 3
12897     if (value == NULL || !PyUnicode_Check(value)) {
12898 #else
12899     if (value == NULL || !PyString_Check(value)) {
12900 #endif
12901         PyErr_SetString(PyExc_TypeError,
12902                         "__name__ must be set to a string object");
12903         return -1;
12904     }
12905     tmp = op->func_name;
12906     Py_INCREF(value);
12907     op->func_name = value;
12908     Py_XDECREF(tmp);
12909     return 0;
12910 }
12911 static PyObject *
12912 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
12913 {
12914     PyObject *self;
12915     self = m->func_closure;
12916     if (self == NULL)
12917         self = Py_None;
12918     Py_INCREF(self);
12919     return self;
12920 }
12921 static PyObject *
12922 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
12923 {
12924     if (op->func_dict == NULL) {
12925         op->func_dict = PyDict_New();
12926         if (op->func_dict == NULL)
12927             return NULL;
12928     }
12929     Py_INCREF(op->func_dict);
12930     return op->func_dict;
12931 }
12932 static int
12933 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
12934 {
12935     PyObject *tmp;
12936     if (value == NULL) {
12937         PyErr_SetString(PyExc_TypeError,
12938                "function's dictionary may not be deleted");
12939         return -1;
12940     }
12941     if (!PyDict_Check(value)) {
12942         PyErr_SetString(PyExc_TypeError,
12943                "setting function's dictionary to a non-dict");
12944         return -1;
12945     }
12946     tmp = op->func_dict;
12947     Py_INCREF(value);
12948     op->func_dict = value;
12949     Py_XDECREF(tmp);
12950     return 0;
12951 }
12952 static PyObject *
12953 __Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op)
12954 {
12955     PyObject* dict = PyModule_GetDict(__pyx_m);
12956     Py_XINCREF(dict);
12957     return dict;
12958 }
12959 static PyObject *
12960 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
12961 {
12962     Py_INCREF(Py_None);
12963     return Py_None;
12964 }
12965 static PyObject *
12966 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
12967 {
12968     PyObject* result = (op->func_code) ? op->func_code : Py_None;
12969     Py_INCREF(result);
12970     return result;
12971 }
12972 static PyObject *
12973 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
12974 {
12975     if (op->defaults_tuple) {
12976         Py_INCREF(op->defaults_tuple);
12977         return op->defaults_tuple;
12978     }
12979     if (op->defaults_getter) {
12980         PyObject *res = op->defaults_getter((PyObject *) op);
12981         if (res) {
12982             Py_INCREF(res);
12983             op->defaults_tuple = res;
12984         }
12985         return res;
12986     }
12987     Py_INCREF(Py_None);
12988     return Py_None;
12989 }
12990 static PyGetSetDef __pyx_CyFunction_getsets[] = {
12991     {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
12992     {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
12993     {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
12994     {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
12995     {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
12996     {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
12997     {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
12998     {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
12999     {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
13000     {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
13001     {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
13002     {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
13003     {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
13004     {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
13005     {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
13006     {0, 0, 0, 0, 0}
13007 };
13008 #ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
13009 #define PY_WRITE_RESTRICTED WRITE_RESTRICTED
13010 #endif
13011 static PyMemberDef __pyx_CyFunction_members[] = {
13012     {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
13013     {0, 0, 0,  0, 0}
13014 };
13015 static PyObject *
13016 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
13017 {
13018 #if PY_MAJOR_VERSION >= 3
13019     return PyUnicode_FromString(m->func.m_ml->ml_name);
13020 #else
13021     return PyString_FromString(m->func.m_ml->ml_name);
13022 #endif
13023 }
13024 static PyMethodDef __pyx_CyFunction_methods[] = {
13025     {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
13026     {0, 0, 0, 0}
13027 };
13028 static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
13029                                       PyObject *closure, PyObject *module, PyObject* code) {
13030     __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
13031     if (op == NULL)
13032         return NULL;
13033     op->flags = flags;
13034     op->func_weakreflist = NULL;
13035     op->func.m_ml = ml;
13036     op->func.m_self = (PyObject *) op;
13037     Py_XINCREF(closure);
13038     op->func_closure = closure;
13039     Py_XINCREF(module);
13040     op->func.m_module = module;
13041     op->func_dict = NULL;
13042     op->func_name = NULL;
13043     op->func_doc = NULL;
13044     op->func_classobj = NULL;
13045     Py_XINCREF(code);
13046     op->func_code = code;
13047     op->defaults_pyobjects = 0;
13048     op->defaults = NULL;
13049     op->defaults_tuple = NULL;
13050     op->defaults_getter = NULL;
13051     PyObject_GC_Track(op);
13052     return (PyObject *) op;
13053 }
13054 static int
13055 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
13056 {
13057     Py_CLEAR(m->func_closure);
13058     Py_CLEAR(m->func.m_module);
13059     Py_CLEAR(m->func_dict);
13060     Py_CLEAR(m->func_name);
13061     Py_CLEAR(m->func_doc);
13062     Py_CLEAR(m->func_code);
13063     Py_CLEAR(m->func_classobj);
13064     Py_CLEAR(m->defaults_tuple);
13065     if (m->defaults) {
13066         PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
13067         int i;
13068         for (i = 0; i < m->defaults_pyobjects; i++)
13069             Py_XDECREF(pydefaults[i]);
13070         PyMem_Free(m->defaults);
13071         m->defaults = NULL;
13072     }
13073     return 0;
13074 }
13075 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
13076 {
13077     PyObject_GC_UnTrack(m);
13078     if (m->func_weakreflist != NULL)
13079         PyObject_ClearWeakRefs((PyObject *) m);
13080     __Pyx_CyFunction_clear(m);
13081     PyObject_GC_Del(m);
13082 }
13083 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
13084 {
13085     Py_VISIT(m->func_closure);
13086     Py_VISIT(m->func.m_module);
13087     Py_VISIT(m->func_dict);
13088     Py_VISIT(m->func_name);
13089     Py_VISIT(m->func_doc);
13090     Py_VISIT(m->func_code);
13091     Py_VISIT(m->func_classobj);
13092     Py_VISIT(m->defaults_tuple);
13093     if (m->defaults) {
13094         PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
13095         int i;
13096         for (i = 0; i < m->defaults_pyobjects; i++)
13097             Py_VISIT(pydefaults[i]);
13098     }
13099     return 0;
13100 }
13101 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
13102 {
13103     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
13104     if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
13105         Py_INCREF(func);
13106         return func;
13107     }
13108     if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
13109         if (type == NULL)
13110             type = (PyObject *)(Py_TYPE(obj));
13111         return PyMethod_New(func,
13112                             type, (PyObject *)(Py_TYPE(type)));
13113     }
13114     if (obj == Py_None)
13115         obj = NULL;
13116     return PyMethod_New(func, obj, type);
13117 }
13118 static PyObject*
13119 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
13120 {
13121     PyObject *func_name = __Pyx_CyFunction_get_name(op);
13122 #if PY_MAJOR_VERSION >= 3
13123     return PyUnicode_FromFormat("<cyfunction %U at %p>",
13124                                 func_name, (void *)op);
13125 #else
13126     return PyString_FromFormat("<cyfunction %s at %p>",
13127                                PyString_AsString(func_name), (void *)op);
13128 #endif
13129 }
13130 #if CYTHON_COMPILING_IN_PYPY
13131 static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
13132     PyCFunctionObject* f = (PyCFunctionObject*)func;
13133     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
13134     PyObject *self = PyCFunction_GET_SELF(func);
13135     Py_ssize_t size;
13136     switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
13137     case METH_VARARGS:
13138         if (likely(kw == NULL) || PyDict_Size(kw) == 0)
13139             return (*meth)(self, arg);
13140         break;
13141     case METH_VARARGS | METH_KEYWORDS:
13142         return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
13143     case METH_NOARGS:
13144         if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
13145             size = PyTuple_GET_SIZE(arg);
13146             if (size == 0)
13147                 return (*meth)(self, NULL);
13148             PyErr_Format(PyExc_TypeError,
13149                 "%.200s() takes no arguments (%zd given)",
13150                 f->m_ml->ml_name, size);
13151             return NULL;
13152         }
13153         break;
13154     case METH_O:
13155         if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
13156             size = PyTuple_GET_SIZE(arg);
13157             if (size == 1)
13158                 return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
13159             PyErr_Format(PyExc_TypeError,
13160                 "%.200s() takes exactly one argument (%zd given)",
13161                 f->m_ml->ml_name, size);
13162             return NULL;
13163         }
13164         break;
13165     default:
13166         PyErr_SetString(PyExc_SystemError, "Bad call flags in "
13167                         "__Pyx_CyFunction_Call. METH_OLDARGS is no "
13168                         "longer supported!");
13169         return NULL;
13170     }
13171     PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
13172                  f->m_ml->ml_name);
13173     return NULL;
13174 }
13175 #else
13176 static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
13177         return PyCFunction_Call(func, arg, kw);
13178 }
13179 #endif
13180 static PyTypeObject __pyx_CyFunctionType_type = {
13181     PyVarObject_HEAD_INIT(0, 0)
13182     __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
13183     sizeof(__pyx_CyFunctionObject),   /*tp_basicsize*/
13184     0,                                  /*tp_itemsize*/
13185     (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
13186     0,                                  /*tp_print*/
13187     0,                                  /*tp_getattr*/
13188     0,                                  /*tp_setattr*/
13189 #if PY_MAJOR_VERSION < 3
13190     0,                                  /*tp_compare*/
13191 #else
13192     0,                                  /*reserved*/
13193 #endif
13194     (reprfunc) __Pyx_CyFunction_repr,   /*tp_repr*/
13195     0,                                  /*tp_as_number*/
13196     0,                                  /*tp_as_sequence*/
13197     0,                                  /*tp_as_mapping*/
13198     0,                                  /*tp_hash*/
13199     __Pyx_CyFunction_Call,              /*tp_call*/
13200     0,                                  /*tp_str*/
13201     0,                                  /*tp_getattro*/
13202     0,                                  /*tp_setattro*/
13203     0,                                  /*tp_as_buffer*/
13204     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
13205     0,                                  /*tp_doc*/
13206     (traverseproc) __Pyx_CyFunction_traverse,   /*tp_traverse*/
13207     (inquiry) __Pyx_CyFunction_clear,   /*tp_clear*/
13208     0,                                  /*tp_richcompare*/
13209     offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
13210     0,                                  /*tp_iter*/
13211     0,                                  /*tp_iternext*/
13212     __pyx_CyFunction_methods,           /*tp_methods*/
13213     __pyx_CyFunction_members,           /*tp_members*/
13214     __pyx_CyFunction_getsets,           /*tp_getset*/
13215     0,                                  /*tp_base*/
13216     0,                                  /*tp_dict*/
13217     __Pyx_CyFunction_descr_get,         /*tp_descr_get*/
13218     0,                                  /*tp_descr_set*/
13219     offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
13220     0,                                  /*tp_init*/
13221     0,                                  /*tp_alloc*/
13222     0,                                  /*tp_new*/
13223     0,                                  /*tp_free*/
13224     0,                                  /*tp_is_gc*/
13225     0,                                  /*tp_bases*/
13226     0,                                  /*tp_mro*/
13227     0,                                  /*tp_cache*/
13228     0,                                  /*tp_subclasses*/
13229     0,                                  /*tp_weaklist*/
13230     0,                                  /*tp_del*/
13231 #if PY_VERSION_HEX >= 0x02060000
13232     0,                                  /*tp_version_tag*/
13233 #endif
13234 };
13235 static int __Pyx_CyFunction_init(void) {
13236 #if !CYTHON_COMPILING_IN_PYPY
13237     __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
13238 #endif
13239     if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
13240         return -1;
13241     __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
13242     return 0;
13243 }
13244 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
13245     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
13246     m->defaults = PyMem_Malloc(size);
13247     if (!m->defaults)
13248         return PyErr_NoMemory();
13249     memset(m->defaults, 0, sizeof(size));
13250     m->defaults_pyobjects = pyobjects;
13251     return m->defaults;
13252 }
13253 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
13254     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
13255     m->defaults_tuple = tuple;
13256     Py_INCREF(tuple);
13257 }
13258
13259 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject* x) {
13260     const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
13261     const int is_unsigned = const_zero < neg_one;
13262     if (sizeof(int32_t) == sizeof(char)) {
13263         if (is_unsigned)
13264             return (int32_t)__Pyx_PyInt_AsUnsignedChar(x);
13265         else
13266             return (int32_t)__Pyx_PyInt_AsSignedChar(x);
13267     } else if (sizeof(int32_t) == sizeof(short)) {
13268         if (is_unsigned)
13269             return (int32_t)__Pyx_PyInt_AsUnsignedShort(x);
13270         else
13271             return (int32_t)__Pyx_PyInt_AsSignedShort(x);
13272     } else if (sizeof(int32_t) == sizeof(int)) {
13273         if (is_unsigned)
13274             return (int32_t)__Pyx_PyInt_AsUnsignedInt(x);
13275         else
13276             return (int32_t)__Pyx_PyInt_AsSignedInt(x);
13277     } else if (sizeof(int32_t) == sizeof(long)) {
13278         if (is_unsigned)
13279             return (int32_t)__Pyx_PyInt_AsUnsignedLong(x);
13280         else
13281             return (int32_t)__Pyx_PyInt_AsSignedLong(x);
13282     } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) {
13283         if (is_unsigned)
13284             return (int32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
13285         else
13286             return (int32_t)__Pyx_PyInt_AsSignedLongLong(x);
13287     }  else {
13288         int32_t val;
13289         PyObject *v = __Pyx_PyNumber_Int(x);
13290         #if PY_VERSION_HEX < 0x03000000
13291         if (likely(v) && !PyLong_Check(v)) {
13292             PyObject *tmp = v;
13293             v = PyNumber_Long(tmp);
13294             Py_DECREF(tmp);
13295         }
13296         #endif
13297         if (likely(v)) {
13298             int one = 1; int is_little = (int)*(unsigned char *)&one;
13299             unsigned char *bytes = (unsigned char *)&val;
13300             int ret = _PyLong_AsByteArray((PyLongObject *)v,
13301                                           bytes, sizeof(val),
13302                                           is_little, !is_unsigned);
13303             Py_DECREF(v);
13304             if (likely(!ret))
13305                 return val;
13306         }
13307         return (int32_t)-1;
13308     }
13309 }
13310
13311 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
13312     const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
13313     const int is_unsigned = neg_one > const_zero;
13314     if (sizeof(unsigned char) < sizeof(long)) {
13315         long val = __Pyx_PyInt_AsLong(x);
13316         if (unlikely(val != (long)(unsigned char)val)) {
13317             if (!unlikely(val == -1 && PyErr_Occurred())) {
13318                 PyErr_SetString(PyExc_OverflowError,
13319                     (is_unsigned && unlikely(val < 0)) ?
13320                     "can't convert negative value to unsigned char" :
13321                     "value too large to convert to unsigned char");
13322             }
13323             return (unsigned char)-1;
13324         }
13325         return (unsigned char)val;
13326     }
13327     return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
13328 }
13329
13330 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
13331     const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
13332     const int is_unsigned = neg_one > const_zero;
13333     if (sizeof(unsigned short) < sizeof(long)) {
13334         long val = __Pyx_PyInt_AsLong(x);
13335         if (unlikely(val != (long)(unsigned short)val)) {
13336             if (!unlikely(val == -1 && PyErr_Occurred())) {
13337                 PyErr_SetString(PyExc_OverflowError,
13338                     (is_unsigned && unlikely(val < 0)) ?
13339                     "can't convert negative value to unsigned short" :
13340                     "value too large to convert to unsigned short");
13341             }
13342             return (unsigned short)-1;
13343         }
13344         return (unsigned short)val;
13345     }
13346     return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
13347 }
13348
13349 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
13350     const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
13351     const int is_unsigned = neg_one > const_zero;
13352     if (sizeof(unsigned int) < sizeof(long)) {
13353         long val = __Pyx_PyInt_AsLong(x);
13354         if (unlikely(val != (long)(unsigned int)val)) {
13355             if (!unlikely(val == -1 && PyErr_Occurred())) {
13356                 PyErr_SetString(PyExc_OverflowError,
13357                     (is_unsigned && unlikely(val < 0)) ?
13358                     "can't convert negative value to unsigned int" :
13359                     "value too large to convert to unsigned int");
13360             }
13361             return (unsigned int)-1;
13362         }
13363         return (unsigned int)val;
13364     }
13365     return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
13366 }
13367
13368 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
13369     const char neg_one = (char)-1, const_zero = 0;
13370     const int is_unsigned = neg_one > const_zero;
13371     if (sizeof(char) < sizeof(long)) {
13372         long val = __Pyx_PyInt_AsLong(x);
13373         if (unlikely(val != (long)(char)val)) {
13374             if (!unlikely(val == -1 && PyErr_Occurred())) {
13375                 PyErr_SetString(PyExc_OverflowError,
13376                     (is_unsigned && unlikely(val < 0)) ?
13377                     "can't convert negative value to char" :
13378                     "value too large to convert to char");
13379             }
13380             return (char)-1;
13381         }
13382         return (char)val;
13383     }
13384     return (char)__Pyx_PyInt_AsLong(x);
13385 }
13386
13387 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
13388     const short neg_one = (short)-1, const_zero = 0;
13389     const int is_unsigned = neg_one > const_zero;
13390     if (sizeof(short) < sizeof(long)) {
13391         long val = __Pyx_PyInt_AsLong(x);
13392         if (unlikely(val != (long)(short)val)) {
13393             if (!unlikely(val == -1 && PyErr_Occurred())) {
13394                 PyErr_SetString(PyExc_OverflowError,
13395                     (is_unsigned && unlikely(val < 0)) ?
13396                     "can't convert negative value to short" :
13397                     "value too large to convert to short");
13398             }
13399             return (short)-1;
13400         }
13401         return (short)val;
13402     }
13403     return (short)__Pyx_PyInt_AsLong(x);
13404 }
13405
13406 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
13407     const int neg_one = (int)-1, const_zero = 0;
13408     const int is_unsigned = neg_one > const_zero;
13409     if (sizeof(int) < sizeof(long)) {
13410         long val = __Pyx_PyInt_AsLong(x);
13411         if (unlikely(val != (long)(int)val)) {
13412             if (!unlikely(val == -1 && PyErr_Occurred())) {
13413                 PyErr_SetString(PyExc_OverflowError,
13414                     (is_unsigned && unlikely(val < 0)) ?
13415                     "can't convert negative value to int" :
13416                     "value too large to convert to int");
13417             }
13418             return (int)-1;
13419         }
13420         return (int)val;
13421     }
13422     return (int)__Pyx_PyInt_AsLong(x);
13423 }
13424
13425 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
13426     const signed char neg_one = (signed char)-1, const_zero = 0;
13427     const int is_unsigned = neg_one > const_zero;
13428     if (sizeof(signed char) < sizeof(long)) {
13429         long val = __Pyx_PyInt_AsLong(x);
13430         if (unlikely(val != (long)(signed char)val)) {
13431             if (!unlikely(val == -1 && PyErr_Occurred())) {
13432                 PyErr_SetString(PyExc_OverflowError,
13433                     (is_unsigned && unlikely(val < 0)) ?
13434                     "can't convert negative value to signed char" :
13435                     "value too large to convert to signed char");
13436             }
13437             return (signed char)-1;
13438         }
13439         return (signed char)val;
13440     }
13441     return (signed char)__Pyx_PyInt_AsSignedLong(x);
13442 }
13443
13444 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
13445     const signed short neg_one = (signed short)-1, const_zero = 0;
13446     const int is_unsigned = neg_one > const_zero;
13447     if (sizeof(signed short) < sizeof(long)) {
13448         long val = __Pyx_PyInt_AsLong(x);
13449         if (unlikely(val != (long)(signed short)val)) {
13450             if (!unlikely(val == -1 && PyErr_Occurred())) {
13451                 PyErr_SetString(PyExc_OverflowError,
13452                     (is_unsigned && unlikely(val < 0)) ?
13453                     "can't convert negative value to signed short" :
13454                     "value too large to convert to signed short");
13455             }
13456             return (signed short)-1;
13457         }
13458         return (signed short)val;
13459     }
13460     return (signed short)__Pyx_PyInt_AsSignedLong(x);
13461 }
13462
13463 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
13464     const signed int neg_one = (signed int)-1, const_zero = 0;
13465     const int is_unsigned = neg_one > const_zero;
13466     if (sizeof(signed int) < sizeof(long)) {
13467         long val = __Pyx_PyInt_AsLong(x);
13468         if (unlikely(val != (long)(signed int)val)) {
13469             if (!unlikely(val == -1 && PyErr_Occurred())) {
13470                 PyErr_SetString(PyExc_OverflowError,
13471                     (is_unsigned && unlikely(val < 0)) ?
13472                     "can't convert negative value to signed int" :
13473                     "value too large to convert to signed int");
13474             }
13475             return (signed int)-1;
13476         }
13477         return (signed int)val;
13478     }
13479     return (signed int)__Pyx_PyInt_AsSignedLong(x);
13480 }
13481
13482 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
13483     const int neg_one = (int)-1, const_zero = 0;
13484     const int is_unsigned = neg_one > const_zero;
13485     if (sizeof(int) < sizeof(long)) {
13486         long val = __Pyx_PyInt_AsLong(x);
13487         if (unlikely(val != (long)(int)val)) {
13488             if (!unlikely(val == -1 && PyErr_Occurred())) {
13489                 PyErr_SetString(PyExc_OverflowError,
13490                     (is_unsigned && unlikely(val < 0)) ?
13491                     "can't convert negative value to int" :
13492                     "value too large to convert to int");
13493             }
13494             return (int)-1;
13495         }
13496         return (int)val;
13497     }
13498     return (int)__Pyx_PyInt_AsLong(x);
13499 }
13500
13501 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
13502     const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
13503     const int is_unsigned = neg_one > const_zero;
13504 #if PY_VERSION_HEX < 0x03000000
13505     if (likely(PyInt_Check(x))) {
13506         long val = PyInt_AS_LONG(x);
13507         if (is_unsigned && unlikely(val < 0)) {
13508             PyErr_SetString(PyExc_OverflowError,
13509                             "can't convert negative value to unsigned long");
13510             return (unsigned long)-1;
13511         }
13512         return (unsigned long)val;
13513     } else
13514 #endif
13515     if (likely(PyLong_Check(x))) {
13516         if (is_unsigned) {
13517             if (unlikely(Py_SIZE(x) < 0)) {
13518                 PyErr_SetString(PyExc_OverflowError,
13519                                 "can't convert negative value to unsigned long");
13520                 return (unsigned long)-1;
13521             }
13522             return (unsigned long)PyLong_AsUnsignedLong(x);
13523         } else {
13524             return (unsigned long)PyLong_AsLong(x);
13525         }
13526     } else {
13527         unsigned long val;
13528         PyObject *tmp = __Pyx_PyNumber_Int(x);
13529         if (!tmp) return (unsigned long)-1;
13530         val = __Pyx_PyInt_AsUnsignedLong(tmp);
13531         Py_DECREF(tmp);
13532         return val;
13533     }
13534 }
13535
13536 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
13537     const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
13538     const int is_unsigned = neg_one > const_zero;
13539 #if PY_VERSION_HEX < 0x03000000
13540     if (likely(PyInt_Check(x))) {
13541         long val = PyInt_AS_LONG(x);
13542         if (is_unsigned && unlikely(val < 0)) {
13543             PyErr_SetString(PyExc_OverflowError,
13544                             "can't convert negative value to unsigned PY_LONG_LONG");
13545             return (unsigned PY_LONG_LONG)-1;
13546         }
13547         return (unsigned PY_LONG_LONG)val;
13548     } else
13549 #endif
13550     if (likely(PyLong_Check(x))) {
13551         if (is_unsigned) {
13552             if (unlikely(Py_SIZE(x) < 0)) {
13553                 PyErr_SetString(PyExc_OverflowError,
13554                                 "can't convert negative value to unsigned PY_LONG_LONG");
13555                 return (unsigned PY_LONG_LONG)-1;
13556             }
13557             return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
13558         } else {
13559             return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
13560         }
13561     } else {
13562         unsigned PY_LONG_LONG val;
13563         PyObject *tmp = __Pyx_PyNumber_Int(x);
13564         if (!tmp) return (unsigned PY_LONG_LONG)-1;
13565         val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
13566         Py_DECREF(tmp);
13567         return val;
13568     }
13569 }
13570
13571 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
13572     const long neg_one = (long)-1, const_zero = 0;
13573     const int is_unsigned = neg_one > const_zero;
13574 #if PY_VERSION_HEX < 0x03000000
13575     if (likely(PyInt_Check(x))) {
13576         long val = PyInt_AS_LONG(x);
13577         if (is_unsigned && unlikely(val < 0)) {
13578             PyErr_SetString(PyExc_OverflowError,
13579                             "can't convert negative value to long");
13580             return (long)-1;
13581         }
13582         return (long)val;
13583     } else
13584 #endif
13585     if (likely(PyLong_Check(x))) {
13586         if (is_unsigned) {
13587             if (unlikely(Py_SIZE(x) < 0)) {
13588                 PyErr_SetString(PyExc_OverflowError,
13589                                 "can't convert negative value to long");
13590                 return (long)-1;
13591             }
13592             return (long)PyLong_AsUnsignedLong(x);
13593         } else {
13594             return (long)PyLong_AsLong(x);
13595         }
13596     } else {
13597         long val;
13598         PyObject *tmp = __Pyx_PyNumber_Int(x);
13599         if (!tmp) return (long)-1;
13600         val = __Pyx_PyInt_AsLong(tmp);
13601         Py_DECREF(tmp);
13602         return val;
13603     }
13604 }
13605
13606 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
13607     const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
13608     const int is_unsigned = neg_one > const_zero;
13609 #if PY_VERSION_HEX < 0x03000000
13610     if (likely(PyInt_Check(x))) {
13611         long val = PyInt_AS_LONG(x);
13612         if (is_unsigned && unlikely(val < 0)) {
13613             PyErr_SetString(PyExc_OverflowError,
13614                             "can't convert negative value to PY_LONG_LONG");
13615             return (PY_LONG_LONG)-1;
13616         }
13617         return (PY_LONG_LONG)val;
13618     } else
13619 #endif
13620     if (likely(PyLong_Check(x))) {
13621         if (is_unsigned) {
13622             if (unlikely(Py_SIZE(x) < 0)) {
13623                 PyErr_SetString(PyExc_OverflowError,
13624                                 "can't convert negative value to PY_LONG_LONG");
13625                 return (PY_LONG_LONG)-1;
13626             }
13627             return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
13628         } else {
13629             return (PY_LONG_LONG)PyLong_AsLongLong(x);
13630         }
13631     } else {
13632         PY_LONG_LONG val;
13633         PyObject *tmp = __Pyx_PyNumber_Int(x);
13634         if (!tmp) return (PY_LONG_LONG)-1;
13635         val = __Pyx_PyInt_AsLongLong(tmp);
13636         Py_DECREF(tmp);
13637         return val;
13638     }
13639 }
13640
13641 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
13642     const signed long neg_one = (signed long)-1, const_zero = 0;
13643     const int is_unsigned = neg_one > const_zero;
13644 #if PY_VERSION_HEX < 0x03000000
13645     if (likely(PyInt_Check(x))) {
13646         long val = PyInt_AS_LONG(x);
13647         if (is_unsigned && unlikely(val < 0)) {
13648             PyErr_SetString(PyExc_OverflowError,
13649                             "can't convert negative value to signed long");
13650             return (signed long)-1;
13651         }
13652         return (signed long)val;
13653     } else
13654 #endif
13655     if (likely(PyLong_Check(x))) {
13656         if (is_unsigned) {
13657             if (unlikely(Py_SIZE(x) < 0)) {
13658                 PyErr_SetString(PyExc_OverflowError,
13659                                 "can't convert negative value to signed long");
13660                 return (signed long)-1;
13661             }
13662             return (signed long)PyLong_AsUnsignedLong(x);
13663         } else {
13664             return (signed long)PyLong_AsLong(x);
13665         }
13666     } else {
13667         signed long val;
13668         PyObject *tmp = __Pyx_PyNumber_Int(x);
13669         if (!tmp) return (signed long)-1;
13670         val = __Pyx_PyInt_AsSignedLong(tmp);
13671         Py_DECREF(tmp);
13672         return val;
13673     }
13674 }
13675
13676 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
13677     const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
13678     const int is_unsigned = neg_one > const_zero;
13679 #if PY_VERSION_HEX < 0x03000000
13680     if (likely(PyInt_Check(x))) {
13681         long val = PyInt_AS_LONG(x);
13682         if (is_unsigned && unlikely(val < 0)) {
13683             PyErr_SetString(PyExc_OverflowError,
13684                             "can't convert negative value to signed PY_LONG_LONG");
13685             return (signed PY_LONG_LONG)-1;
13686         }
13687         return (signed PY_LONG_LONG)val;
13688     } else
13689 #endif
13690     if (likely(PyLong_Check(x))) {
13691         if (is_unsigned) {
13692             if (unlikely(Py_SIZE(x) < 0)) {
13693                 PyErr_SetString(PyExc_OverflowError,
13694                                 "can't convert negative value to signed PY_LONG_LONG");
13695                 return (signed PY_LONG_LONG)-1;
13696             }
13697             return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
13698         } else {
13699             return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
13700         }
13701     } else {
13702         signed PY_LONG_LONG val;
13703         PyObject *tmp = __Pyx_PyNumber_Int(x);
13704         if (!tmp) return (signed PY_LONG_LONG)-1;
13705         val = __Pyx_PyInt_AsSignedLongLong(tmp);
13706         Py_DECREF(tmp);
13707         return val;
13708     }
13709 }
13710
13711 static int __Pyx_check_binary_version(void) {
13712     char ctversion[4], rtversion[4];
13713     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
13714     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
13715     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
13716         char message[200];
13717         PyOS_snprintf(message, sizeof(message),
13718                       "compiletime version %s of module '%.100s' "
13719                       "does not match runtime version %s",
13720                       ctversion, __Pyx_MODULE_NAME, rtversion);
13721         #if PY_VERSION_HEX < 0x02050000
13722         return PyErr_Warn(NULL, message);
13723         #else
13724         return PyErr_WarnEx(NULL, message, 1);
13725         #endif
13726     }
13727     return 0;
13728 }
13729
13730 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
13731 #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
13732     PyObject *ob = PyCapsule_New(vtable, 0, 0);
13733 #else
13734     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
13735 #endif
13736     if (!ob)
13737         goto bad;
13738     if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
13739         goto bad;
13740     Py_DECREF(ob);
13741     return 0;
13742 bad:
13743     Py_XDECREF(ob);
13744     return -1;
13745 }
13746
13747 #ifndef __PYX_HAVE_RT_ImportModule
13748 #define __PYX_HAVE_RT_ImportModule
13749 static PyObject *__Pyx_ImportModule(const char *name) {
13750     PyObject *py_name = 0;
13751     PyObject *py_module = 0;
13752     py_name = __Pyx_PyIdentifier_FromString(name);
13753     if (!py_name)
13754         goto bad;
13755     py_module = PyImport_Import(py_name);
13756     Py_DECREF(py_name);
13757     return py_module;
13758 bad:
13759     Py_XDECREF(py_name);
13760     return 0;
13761 }
13762 #endif
13763
13764 #ifndef __PYX_HAVE_RT_ImportType
13765 #define __PYX_HAVE_RT_ImportType
13766 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
13767     size_t size, int strict)
13768 {
13769     PyObject *py_module = 0;
13770     PyObject *result = 0;
13771     PyObject *py_name = 0;
13772     char warning[200];
13773     py_module = __Pyx_ImportModule(module_name);
13774     if (!py_module)
13775         goto bad;
13776     py_name = __Pyx_PyIdentifier_FromString(class_name);
13777     if (!py_name)
13778         goto bad;
13779     result = PyObject_GetAttr(py_module, py_name);
13780     Py_DECREF(py_name);
13781     py_name = 0;
13782     Py_DECREF(py_module);
13783     py_module = 0;
13784     if (!result)
13785         goto bad;
13786     if (!PyType_Check(result)) {
13787         PyErr_Format(PyExc_TypeError,
13788             "%s.%s is not a type object",
13789             module_name, class_name);
13790         goto bad;
13791     }
13792     if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
13793         PyOS_snprintf(warning, sizeof(warning),
13794             "%s.%s size changed, may indicate binary incompatibility",
13795             module_name, class_name);
13796         #if PY_VERSION_HEX < 0x02050000
13797         if (PyErr_Warn(NULL, warning) < 0) goto bad;
13798         #else
13799         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
13800         #endif
13801     }
13802     else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
13803         PyErr_Format(PyExc_ValueError,
13804             "%s.%s has the wrong size, try recompiling",
13805             module_name, class_name);
13806         goto bad;
13807     }
13808     return (PyTypeObject *)result;
13809 bad:
13810     Py_XDECREF(py_module);
13811     Py_XDECREF(result);
13812     return NULL;
13813 }
13814 #endif
13815
13816 static void* __Pyx_GetVtable(PyObject *dict) {
13817     void* ptr;
13818     PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
13819     if (!ob)
13820         goto bad;
13821 #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
13822     ptr = PyCapsule_GetPointer(ob, 0);
13823 #else
13824     ptr = PyCObject_AsVoidPtr(ob);
13825 #endif
13826     if (!ptr && !PyErr_Occurred())
13827         PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
13828     Py_DECREF(ob);
13829     return ptr;
13830 bad:
13831     Py_XDECREF(ob);
13832     return NULL;
13833 }
13834
13835 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
13836     int start = 0, mid = 0, end = count - 1;
13837     if (end >= 0 && code_line > entries[end].code_line) {
13838         return count;
13839     }
13840     while (start < end) {
13841         mid = (start + end) / 2;
13842         if (code_line < entries[mid].code_line) {
13843             end = mid;
13844         } else if (code_line > entries[mid].code_line) {
13845              start = mid + 1;
13846         } else {
13847             return mid;
13848         }
13849     }
13850     if (code_line <= entries[mid].code_line) {
13851         return mid;
13852     } else {
13853         return mid + 1;
13854     }
13855 }
13856 static PyCodeObject *__pyx_find_code_object(int code_line) {
13857     PyCodeObject* code_object;
13858     int pos;
13859     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
13860         return NULL;
13861     }
13862     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
13863     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
13864         return NULL;
13865     }
13866     code_object = __pyx_code_cache.entries[pos].code_object;
13867     Py_INCREF(code_object);
13868     return code_object;
13869 }
13870 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
13871     int pos, i;
13872     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
13873     if (unlikely(!code_line)) {
13874         return;
13875     }
13876     if (unlikely(!entries)) {
13877         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
13878         if (likely(entries)) {
13879             __pyx_code_cache.entries = entries;
13880             __pyx_code_cache.max_count = 64;
13881             __pyx_code_cache.count = 1;
13882             entries[0].code_line = code_line;
13883             entries[0].code_object = code_object;
13884             Py_INCREF(code_object);
13885         }
13886         return;
13887     }
13888     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
13889     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
13890         PyCodeObject* tmp = entries[pos].code_object;
13891         entries[pos].code_object = code_object;
13892         Py_DECREF(tmp);
13893         return;
13894     }
13895     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
13896         int new_max = __pyx_code_cache.max_count + 64;
13897         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
13898             __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
13899         if (unlikely(!entries)) {
13900             return;
13901         }
13902         __pyx_code_cache.entries = entries;
13903         __pyx_code_cache.max_count = new_max;
13904     }
13905     for (i=__pyx_code_cache.count; i>pos; i--) {
13906         entries[i] = entries[i-1];
13907     }
13908     entries[pos].code_line = code_line;
13909     entries[pos].code_object = code_object;
13910     __pyx_code_cache.count++;
13911     Py_INCREF(code_object);
13912 }
13913
13914 #include "compile.h"
13915 #include "frameobject.h"
13916 #include "traceback.h"
13917 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
13918             const char *funcname, int c_line,
13919             int py_line, const char *filename) {
13920     PyCodeObject *py_code = 0;
13921     PyObject *py_srcfile = 0;
13922     PyObject *py_funcname = 0;
13923     #if PY_MAJOR_VERSION < 3
13924     py_srcfile = PyString_FromString(filename);
13925     #else
13926     py_srcfile = PyUnicode_FromString(filename);
13927     #endif
13928     if (!py_srcfile) goto bad;
13929     if (c_line) {
13930         #if PY_MAJOR_VERSION < 3
13931         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
13932         #else
13933         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
13934         #endif
13935     }
13936     else {
13937         #if PY_MAJOR_VERSION < 3
13938         py_funcname = PyString_FromString(funcname);
13939         #else
13940         py_funcname = PyUnicode_FromString(funcname);
13941         #endif
13942     }
13943     if (!py_funcname) goto bad;
13944     py_code = __Pyx_PyCode_New(
13945         0,            /*int argcount,*/
13946         0,            /*int kwonlyargcount,*/
13947         0,            /*int nlocals,*/
13948         0,            /*int stacksize,*/
13949         0,            /*int flags,*/
13950         __pyx_empty_bytes, /*PyObject *code,*/
13951         __pyx_empty_tuple, /*PyObject *consts,*/
13952         __pyx_empty_tuple, /*PyObject *names,*/
13953         __pyx_empty_tuple, /*PyObject *varnames,*/
13954         __pyx_empty_tuple, /*PyObject *freevars,*/
13955         __pyx_empty_tuple, /*PyObject *cellvars,*/
13956         py_srcfile,   /*PyObject *filename,*/
13957         py_funcname,  /*PyObject *name,*/
13958         py_line,      /*int firstlineno,*/
13959         __pyx_empty_bytes  /*PyObject *lnotab*/
13960     );
13961     Py_DECREF(py_srcfile);
13962     Py_DECREF(py_funcname);
13963     return py_code;
13964 bad:
13965     Py_XDECREF(py_srcfile);
13966     Py_XDECREF(py_funcname);
13967     return NULL;
13968 }
13969 static void __Pyx_AddTraceback(const char *funcname, int c_line,
13970                                int py_line, const char *filename) {
13971     PyCodeObject *py_code = 0;
13972     PyObject *py_globals = 0;
13973     PyFrameObject *py_frame = 0;
13974     py_code = __pyx_find_code_object(c_line ? c_line : py_line);
13975     if (!py_code) {
13976         py_code = __Pyx_CreateCodeObjectForTraceback(
13977             funcname, c_line, py_line, filename);
13978         if (!py_code) goto bad;
13979         __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
13980     }
13981     py_globals = PyModule_GetDict(__pyx_m);
13982     if (!py_globals) goto bad;
13983     py_frame = PyFrame_New(
13984         PyThreadState_GET(), /*PyThreadState *tstate,*/
13985         py_code,             /*PyCodeObject *code,*/
13986         py_globals,          /*PyObject *globals,*/
13987         0                    /*PyObject *locals*/
13988     );
13989     if (!py_frame) goto bad;
13990     py_frame->f_lineno = py_line;
13991     PyTraceBack_Here(py_frame);
13992 bad:
13993     Py_XDECREF(py_code);
13994     Py_XDECREF(py_frame);
13995 }
13996
13997 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
13998     while (t->p) {
13999         #if PY_MAJOR_VERSION < 3
14000         if (t->is_unicode) {
14001             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
14002         } else if (t->intern) {
14003             *t->p = PyString_InternFromString(t->s);
14004         } else {
14005             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
14006         }
14007         #else  /* Python 3+ has unicode identifiers */
14008         if (t->is_unicode | t->is_str) {
14009             if (t->intern) {
14010                 *t->p = PyUnicode_InternFromString(t->s);
14011             } else if (t->encoding) {
14012                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
14013             } else {
14014                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
14015             }
14016         } else {
14017             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
14018         }
14019         #endif
14020         if (!*t->p)
14021             return -1;
14022         ++t;
14023     }
14024     return 0;
14025 }
14026
14027
14028 /* Type Conversion Functions */
14029
14030 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
14031    int is_true = x == Py_True;
14032    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
14033    else return PyObject_IsTrue(x);
14034 }
14035
14036 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
14037   PyNumberMethods *m;
14038   const char *name = NULL;
14039   PyObject *res = NULL;
14040 #if PY_VERSION_HEX < 0x03000000
14041   if (PyInt_Check(x) || PyLong_Check(x))
14042 #else
14043   if (PyLong_Check(x))
14044 #endif
14045     return Py_INCREF(x), x;
14046   m = Py_TYPE(x)->tp_as_number;
14047 #if PY_VERSION_HEX < 0x03000000
14048   if (m && m->nb_int) {
14049     name = "int";
14050     res = PyNumber_Int(x);
14051   }
14052   else if (m && m->nb_long) {
14053     name = "long";
14054     res = PyNumber_Long(x);
14055   }
14056 #else
14057   if (m && m->nb_int) {
14058     name = "int";
14059     res = PyNumber_Long(x);
14060   }
14061 #endif
14062   if (res) {
14063 #if PY_VERSION_HEX < 0x03000000
14064     if (!PyInt_Check(res) && !PyLong_Check(res)) {
14065 #else
14066     if (!PyLong_Check(res)) {
14067 #endif
14068       PyErr_Format(PyExc_TypeError,
14069                    "__%s__ returned non-%s (type %.200s)",
14070                    name, name, Py_TYPE(res)->tp_name);
14071       Py_DECREF(res);
14072       return NULL;
14073     }
14074   }
14075   else if (!PyErr_Occurred()) {
14076     PyErr_SetString(PyExc_TypeError,
14077                     "an integer is required");
14078   }
14079   return res;
14080 }
14081
14082 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
14083   Py_ssize_t ival;
14084   PyObject* x = PyNumber_Index(b);
14085   if (!x) return -1;
14086   ival = PyInt_AsSsize_t(x);
14087   Py_DECREF(x);
14088   return ival;
14089 }
14090
14091 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
14092 #if PY_VERSION_HEX < 0x02050000
14093    if (ival <= LONG_MAX)
14094        return PyInt_FromLong((long)ival);
14095    else {
14096        unsigned char *bytes = (unsigned char *) &ival;
14097        int one = 1; int little = (int)*(unsigned char*)&one;
14098        return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
14099    }
14100 #else
14101    return PyInt_FromSize_t(ival);
14102 #endif
14103 }
14104
14105 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
14106    unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
14107    if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
14108        return (size_t)-1;
14109    } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
14110        PyErr_SetString(PyExc_OverflowError,
14111                        "value too large to convert to size_t");
14112        return (size_t)-1;
14113    }
14114    return (size_t)val;
14115 }
14116
14117
14118 #endif /* Py_PYTHON_H */