/* Generated by Cython 0.17.4 on Fri Apr 19 15:24:08 2013 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define CYTHON_FORMAT_SSIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
                                  !PyComplex_Check(o))
  #define PyIndex_Check __Pyx_PyIndex_Check
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
  #define CYTHON_FORMAT_SSIZE_T "z"
  #define __Pyx_PyIndex_Check PyIndex_Check
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)
  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;
  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__GatEngine
#define __PYX_HAVE_API__GatEngine
#include "string.h"
#include "stdlib.h"
#include "stdint.h"
#include "stdio.h"
#include "math.h"
#include "errno.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "sys/mman.h"
#include "unistd.h"
#include "fileobject.h"
#include "gat_utils.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

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*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))

#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "GatEngine.pyx",
  "numpy.pxd",
  "GatEngine.pxd",
  "GatSegmentList.pxd",
  "type.pxd",
};
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name; /* for error messages only */
  struct __Pyx_StructField_* fields;
  size_t size;     /* sizeof(type) */
  size_t arraysize[8]; /* length of array in each dimension */
  int ndim;
  char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;


/* "GatSegmentList.pxd":137
 * #####################################################
 * # type for positions
 * ctypedef unsigned int Position             # <<<<<<<<<<<<<<
 * # type for position difference - can be negative
 * ctypedef int PositionDifference
 */
typedef unsigned int __pyx_t_14GatSegmentList_Position;

/* "GatSegmentList.pxd":139
 * ctypedef unsigned int Position
 * # type for position difference - can be negative
 * ctypedef int PositionDifference             # <<<<<<<<<<<<<<
 * 
 * # A segment (without strand)
 */
typedef int __pyx_t_14GatSegmentList_PositionDifference;

/* "numpy.pxd":723
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "numpy.pxd":724
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "numpy.pxd":725
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "numpy.pxd":726
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "numpy.pxd":730
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "numpy.pxd":731
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "numpy.pxd":732
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "numpy.pxd":733
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "numpy.pxd":737
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "numpy.pxd":738
 * 
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "numpy.pxd":747
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "numpy.pxd":748
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "numpy.pxd":749
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "numpy.pxd":751
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "numpy.pxd":752
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "numpy.pxd":753
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "numpy.pxd":755
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "numpy.pxd":756
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "numpy.pxd":758
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "numpy.pxd":759
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "numpy.pxd":760
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

/* "GatEngine.pyx":24
 * cimport numpy
 * DTYPE_INT = numpy.int
 * ctypedef numpy.int_t DTYPE_INT_t             # <<<<<<<<<<<<<<
 * DTYPE_FLOAT = numpy.float
 * ctypedef numpy.float_t DTYPE_FLOAT_t
 */
typedef __pyx_t_5numpy_int_t __pyx_t_9GatEngine_DTYPE_INT_t;

/* "GatEngine.pyx":26
 * ctypedef numpy.int_t DTYPE_INT_t
 * DTYPE_FLOAT = numpy.float
 * ctypedef numpy.float_t DTYPE_FLOAT_t             # <<<<<<<<<<<<<<
 * 
 * #####################################################
 */
typedef __pyx_t_5numpy_float_t __pyx_t_9GatEngine_DTYPE_FLOAT_t;
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif


/*--- Type declarations ---*/
struct __pyx_obj_9GatEngine_Sampler;
struct __pyx_obj_9GatEngine_SamplerGlobalPermutation;
struct __pyx_obj_9GatEngine_IntervalContainer;
struct __pyx_obj_9GatEngine_IntervalCollection;
struct __pyx_obj_9GatEngine_Samples;
struct __pyx_obj_9GatEngine_SamplesFile;
struct __pyx_obj_9GatEngine_TupleProxy;
struct __pyx_obj_9GatEngine_SegmentListSampler;
struct __pyx_obj_9GatEngine_SamplerLocalPermutation;
struct __pyx_obj_9GatEngine_SamplerShift;
struct __pyx_obj_9GatEngine_SamplerSegments;
struct __pyx_obj_14GatSegmentList_SegmentList;
struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects;
struct __pyx_obj_9GatEngine___pyx_scope_struct____str__;
struct __pyx_obj_9GatEngine_IntervalDictionary;
struct __pyx_obj_9GatEngine_Counter;
struct __pyx_obj_9GatEngine_CounterAnnotationMidpointOverlap;
struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists;
struct __pyx_obj_9GatEngine_AnnotatorResult;
struct __pyx_obj_9GatEngine_AnnotatorResultExtended;
struct __pyx_obj_9GatEngine_CounterNucleotideOverlap;
struct __pyx_obj_9GatEngine_SegmentListSamplerSlow;
struct __pyx_obj_9GatEngine_CounterSegmentMidpointOverlap;
struct __pyx_obj_9GatEngine_SamplerUniform;
struct __pyx_obj_9GatEngine_BedProxy;
struct __pyx_obj_9GatEngine_CounterAnnotationOverlap;
struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists;
struct __pyx_obj_9GatEngine_SamplesCached;
struct __pyx_obj_9GatEngine_SamplerDummy;
struct __pyx_obj_9GatEngine_SamplerBruteForce;
struct __pyx_obj_9GatEngine_CounterSegmentOverlap;
struct __pyx_obj_9GatEngine_SamplerAnnotator;
struct __pyx_obj_9GatEngine_HistogramSampler;
struct __pyx_obj_9GatEngine_CounterNucleotideDensity;
struct __pyx_obj_9GatEngine_HistogramSamplerSlow;
struct __pyx_t_14GatSegmentList_Segment;
struct __pyx_opt_args_14GatSegmentList_11SegmentList_intersectionWithSegments;

/* "GatSegmentList.pxd":142
 * 
 * # A segment (without strand)
 * cdef struct Segment:             # <<<<<<<<<<<<<<
 *     Position start
 *     Position end
 */
struct __pyx_t_14GatSegmentList_Segment {
  __pyx_t_14GatSegmentList_Position start;
  __pyx_t_14GatSegmentList_Position end;
};

/* "GatSegmentList.pxd":174
 *     cpdef SegmentList getOverlappingSegmentsWithRange( self, Position start, Position end )
 *     cpdef Position overlapWithSegments( self, SegmentList other )
 *     cpdef Position intersectionWithSegments( self, SegmentList other, mode = * )             # <<<<<<<<<<<<<<
 *     cpdef SegmentList getFilledSegmentsFromStart( self, Position start, PositionDifference remainder )
 *     cpdef SegmentList getFilledSegmentsFromEnd( self, Position end, PositionDifference remainder )
 */
struct __pyx_opt_args_14GatSegmentList_11SegmentList_intersectionWithSegments {
  int __pyx_n;
  PyObject *mode;
};

/* "numpy.pxd":762
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "numpy.pxd":763
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "numpy.pxd":764
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "numpy.pxd":766
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_t_9GatEngine_EnrichmentStatistics;
typedef struct __pyx_t_9GatEngine_EnrichmentStatistics __pyx_t_9GatEngine_EnrichmentStatistics;

/* "GatEngine.pyx":1483
 * ## Annotator results
 * ############################################################
 * ctypedef struct EnrichmentStatistics:             # <<<<<<<<<<<<<<
 *     double expected
 *     double observed
 */
struct __pyx_t_9GatEngine_EnrichmentStatistics {
  double expected;
  double observed;
  double stddev;
  double lower95;
  double upper95;
  double fold;
  __pyx_t_14GatSegmentList_Position nsamples;
  double *samples;
  int *sorted2sample;
  int *sample2sorted;
  double pvalue;
  double qvalue;
};

/* "GatEngine.pyx":408
 *             self.cdf = NULL
 * 
 * cdef class Sampler:             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_9GatEngine_Sampler {
  PyObject_HEAD
};


/* "GatEngine.pyx":1198
 * ########################################################
 * ########################################################
 * cdef class SamplerGlobalPermutation(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     Sample segments by global permutation.
 */
struct __pyx_obj_9GatEngine_SamplerGlobalPermutation {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerGlobalPermutation *__pyx_vtab;
};


/* "GatEngine.pxd":131
 *     int fromCompressedFile( unsigned char *, size_t, FILE *)
 * 
 * cdef class IntervalContainer:             # <<<<<<<<<<<<<<
 *     cdef int shared_fd
 *     cdef str shared_fn
 */
struct __pyx_obj_9GatEngine_IntervalContainer {
  PyObject_HEAD
  int shared_fd;
  PyObject *shared_fn;
  PyObject *intervals;
  PyObject *name;
};


/* "GatEngine.pxd":140
 *     pass
 * 
 * cdef class IntervalCollection(IntervalContainer):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_9GatEngine_IntervalCollection {
  struct __pyx_obj_9GatEngine_IntervalContainer __pyx_base;
};


/* "GatEngine.pyx":3038
 * ## samples
 * #####################################################################
 * cdef class Samples( object ):             # <<<<<<<<<<<<<<
 *     '''a collection of samples.
 * 
 */
struct __pyx_obj_9GatEngine_Samples {
  PyObject_HEAD
  PyObject *samples;
};


/* "GatEngine.pyx":3081
 *         return len(self.samples)
 * 
 * cdef class SamplesFile( Samples ):             # <<<<<<<<<<<<<<
 *     '''a collection of samples.
 * 
 */
struct __pyx_obj_9GatEngine_SamplesFile {
  struct __pyx_obj_9GatEngine_Samples __pyx_base;
};


/* "GatEngine.pyx":2154
 * ## Quick parsing of tabular files (bed, gff)
 * ############################################################
 * cdef class TupleProxy:             # <<<<<<<<<<<<<<
 *     '''Proxy class for access to parsed row as a tuple.
 * 
 */
struct __pyx_obj_9GatEngine_TupleProxy {
  PyObject_HEAD
  struct __pyx_vtabstruct_9GatEngine_TupleProxy *__pyx_vtab;
  char *data;
  char **fields;
  int nfields;
  int index;
  int min_fields;
};


/* "GatEngine.pyx":214
 *             self.cdf = NULL
 * 
 * cdef class SegmentListSampler:             # <<<<<<<<<<<<<<
 *     '''return a new position within segment list.
 * 
 */
struct __pyx_obj_9GatEngine_SegmentListSampler {
  PyObject_HEAD
  struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *__pyx_vtab;
  struct __pyx_obj_14GatSegmentList_SegmentList *segment_list;
  __pyx_t_14GatSegmentList_Position *cdf;
  __pyx_t_14GatSegmentList_Position total_size;
  int nsegments;
};


/* "GatEngine.pyx":1081
 * ########################################################
 * ########################################################
 * cdef class SamplerLocalPermutation(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     Sample segments by local permutation.
 */
struct __pyx_obj_9GatEngine_SamplerLocalPermutation {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerLocalPermutation *__pyx_vtab;
};


/* "GatEngine.pyx":962
 * ########################################################
 * ########################################################
 * cdef class SamplerShift(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     Sample segments by shifting them by a random amount within *radius*
 */
struct __pyx_obj_9GatEngine_SamplerShift {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerShift *__pyx_vtab;
  double radius;
  int extension;
};


/* "GatEngine.pyx":617
 * ########################################################
 * ########################################################
 * cdef class SamplerSegments(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     sample *n* segments from segment length distribution.
 */
struct __pyx_obj_9GatEngine_SamplerSegments {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerSegments *__pyx_vtab;
  __pyx_t_14GatSegmentList_Position bucket_size;
  __pyx_t_14GatSegmentList_Position nbuckets;
};


/* "GatSegmentList.pxd":150
 * ## definition of segmentlist
 * #####################################################
 * cdef class SegmentList:             # <<<<<<<<<<<<<<
 * 
 *     cdef Segment * segments
 */
struct __pyx_obj_14GatSegmentList_SegmentList {
  PyObject_HEAD
  struct __pyx_vtabstruct_14GatSegmentList_SegmentList *__pyx_vtab;
  struct __pyx_t_14GatSegmentList_Segment *segments;
  size_t nsegments;
  size_t allocated;
  int flag;
  int chunk_size;
  int shared_fd;
  PyObject *key;
};


/* "GatEngine.pyx":143
 *         return pos, overlap
 * 
 * cdef class SegmentListSamplerWithEdgeEffects:             # <<<<<<<<<<<<<<
 * 
 *     cdef SegmentList segment_list
 */
struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects {
  PyObject_HEAD
  struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_vtab;
  struct __pyx_obj_14GatSegmentList_SegmentList *segment_list;
  __pyx_t_14GatSegmentList_Position *cdf;
  __pyx_t_14GatSegmentList_Position total_size;
  __pyx_t_14GatSegmentList_Position nsegments;
};


/* "GatEngine.pyx":1877
 *         self.workspace_size = workspace.sum()
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 * 
 *         # if self.stats.nsamples < 10**6:
 */
struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ {
  PyObject_HEAD
  struct __pyx_obj_9GatEngine_AnnotatorResultExtended *__pyx_v_self;
};


/* "GatEngine.pxd":137
 *     cdef str name
 * 
 * cdef class IntervalDictionary(IntervalContainer):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_9GatEngine_IntervalDictionary {
  struct __pyx_obj_9GatEngine_IntervalContainer __pyx_base;
};


/* "GatEngine.pyx":1376
 * ## Counters
 * ############################################################
 * cdef class Counter:             # <<<<<<<<<<<<<<
 *     '''base class for objects that compute counts
 *     between two segment lists.
 */
struct __pyx_obj_9GatEngine_Counter {
  PyObject_HEAD
};


/* "GatEngine.pyx":1421
 *         return annotations.intersectionWithSegments( segments )
 * 
 * cdef class CounterAnnotationMidpointOverlap(Counter):             # <<<<<<<<<<<<<<
 *     name = "annotation-midoverlap"
 * 
 */
struct __pyx_obj_9GatEngine_CounterAnnotationMidpointOverlap {
  struct __pyx_obj_9GatEngine_Counter __pyx_base;
};


/* "GatEngine.pyx":2678
 * 
 * 
 *     def getSegmentLists( self ):             # <<<<<<<<<<<<<<
 *         '''yield all segment lists.'''
 *         for contig, segmentlist in self.intervals.iteritems():
 */
struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists {
  PyObject_HEAD
  PyObject *__pyx_v_contig;
  PyObject *__pyx_v_segmentlist;
  struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
};


/* "GatEngine.pyx":1677
 * ## Annotator results
 * ############################################################
 * cdef class AnnotatorResult(object):             # <<<<<<<<<<<<<<
 *     '''container for annotator results.'''
 * 
 */
struct __pyx_obj_9GatEngine_AnnotatorResult {
  PyObject_HEAD
  PyObject *format_observed;
  __pyx_t_9GatEngine_EnrichmentStatistics *stats;
  PyObject *track;
  PyObject *annotation;
  PyObject *counter;
};


/* "GatEngine.pyx":1806
 *         return getTwoSidedPValue( self.stats, value )
 * 
 * cdef class AnnotatorResultExtended(AnnotatorResult):             # <<<<<<<<<<<<<<
 *     '''container for annotator results.'''
 * 
 */
struct __pyx_obj_9GatEngine_AnnotatorResultExtended {
  struct __pyx_obj_9GatEngine_AnnotatorResult __pyx_base;
  __pyx_t_14GatSegmentList_Position track_nsegments;
  __pyx_t_14GatSegmentList_Position track_size;
  __pyx_t_14GatSegmentList_Position annotation_nsegments;
  __pyx_t_14GatSegmentList_Position annotation_size;
  __pyx_t_14GatSegmentList_Position overlap_nsegments;
  __pyx_t_14GatSegmentList_Position overlap_size;
  __pyx_t_14GatSegmentList_Position workspace_size;
};


/* "GatEngine.pyx":1381
 *     '''
 * 
 * cdef class CounterNucleotideOverlap(Counter):             # <<<<<<<<<<<<<<
 *     name = "nucleotide-overlap"
 * 
 */
struct __pyx_obj_9GatEngine_CounterNucleotideOverlap {
  struct __pyx_obj_9GatEngine_Counter __pyx_base;
};


/* "GatEngine.pyx":104
 *     return (da > db) - (da < db)
 * 
 * cdef class SegmentListSamplerSlow:             # <<<<<<<<<<<<<<
 * 
 *     cdef SegmentList segment_list
 */
struct __pyx_obj_9GatEngine_SegmentListSamplerSlow {
  PyObject_HEAD
  struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerSlow *__pyx_vtab;
  struct __pyx_obj_14GatSegmentList_SegmentList *segment_list;
  PyArrayObject *cdf;
  __pyx_t_14GatSegmentList_Position total_size;
};


/* "GatEngine.pyx":1407
 *         return segments.intersectionWithSegments( annotations )
 * 
 * cdef class CounterSegmentMidpointOverlap(Counter):             # <<<<<<<<<<<<<<
 *     name = "segment-midoverlap"
 * 
 */
struct __pyx_obj_9GatEngine_CounterSegmentMidpointOverlap {
  struct __pyx_obj_9GatEngine_Counter __pyx_base;
};


/* "GatEngine.pyx":842
 * ########################################################
 * ########################################################
 * cdef class SamplerUniform(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     For debugging purposes.
 */
struct __pyx_obj_9GatEngine_SamplerUniform {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerUniform *__pyx_vtab;
  __pyx_t_14GatSegmentList_Position bucket_size;
  __pyx_t_14GatSegmentList_Position nbuckets;
  __pyx_t_14GatSegmentList_Position increment;
  __pyx_t_14GatSegmentList_Position current_workspace;
  __pyx_t_14GatSegmentList_Position current_position;
  int current_orientation;
};


/* "GatEngine.pyx":2284
 *         return self.fields[self.index-1]
 * 
 * cdef class BedProxy( TupleProxy ):             # <<<<<<<<<<<<<<
 * 
 *    cdef track
 */
struct __pyx_obj_9GatEngine_BedProxy {
  struct __pyx_obj_9GatEngine_TupleProxy __pyx_base;
  PyObject *track;
};


/* "GatEngine.pyx":1414
 *         return segments.intersectionWithSegments( annotations, mode = "midpoint" )
 * 
 * cdef class CounterAnnotationOverlap(Counter):             # <<<<<<<<<<<<<<
 *     name = "annotation-overlap"
 * 
 */
struct __pyx_obj_9GatEngine_CounterAnnotationOverlap {
  struct __pyx_obj_9GatEngine_Counter __pyx_base;
};


/* "GatEngine.pyx":2810
 *                                           self.intervals ))
 * 
 *     def getSegmentLists( self ):             # <<<<<<<<<<<<<<
 *         '''yield all segment lists.'''
 *         for track,v in self.intervals.iteritems():
 */
struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists {
  PyObject_HEAD
  PyObject *__pyx_v_contig;
  PyObject *__pyx_v_segmentlist;
  struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self;
  PyObject *__pyx_v_track;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
};


/* "GatEngine.pyx":3104
 *         return True
 * 
 * cdef class SamplesCached( Samples ):             # <<<<<<<<<<<<<<
 *     '''a collection of samples.
 * 
 */
struct __pyx_obj_9GatEngine_SamplesCached {
  struct __pyx_obj_9GatEngine_Samples __pyx_base;
  FILE *fcache;
  FILE *findex;
  PyObject *index;
  char *filename;
};


/* "GatEngine.pyx":1355
 * ########################################################
 * ########################################################
 * cdef class SamplerDummy(Sampler):             # <<<<<<<<<<<<<<
 * 
 *     def __init__( self ):
 */
struct __pyx_obj_9GatEngine_SamplerDummy {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerDummy *__pyx_vtab;
};


/* "GatEngine.pyx":709
 * ########################################################
 * ########################################################
 * cdef class SamplerBruteForce(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     sample segments from length distribution until
 */
struct __pyx_obj_9GatEngine_SamplerBruteForce {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerBruteForce *__pyx_vtab;
  __pyx_t_14GatSegmentList_Position bucket_size;
  __pyx_t_14GatSegmentList_Position nbuckets;
  int ntries_inner;
  int ntries_outer;
};


/* "GatEngine.pyx":1400
 *         return float(annotations.overlapWithSegments( segments )) / l
 * 
 * cdef class CounterSegmentOverlap(Counter):             # <<<<<<<<<<<<<<
 *     name = "segment-overlap"
 * 
 */
struct __pyx_obj_9GatEngine_CounterSegmentOverlap {
  struct __pyx_obj_9GatEngine_Counter __pyx_base;
};


/* "GatEngine.pyx":411
 *     pass
 * 
 * cdef class SamplerAnnotator(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     sample with the annotator method.
 */
struct __pyx_obj_9GatEngine_SamplerAnnotator {
  struct __pyx_obj_9GatEngine_Sampler __pyx_base;
  struct __pyx_vtabstruct_9GatEngine_SamplerAnnotator *__pyx_vtab;
  __pyx_t_14GatSegmentList_Position bucket_size;
  int nbuckets;
  int nunsuccessful_rounds;
};


/* "GatEngine.pyx":353
 *         return base
 * 
 * cdef class HistogramSampler:             # <<<<<<<<<<<<<<
 * 
 *     cdef Position * cdf
 */
struct __pyx_obj_9GatEngine_HistogramSampler {
  PyObject_HEAD
  struct __pyx_vtabstruct_9GatEngine_HistogramSampler *__pyx_vtab;
  __pyx_t_14GatSegmentList_Position *cdf;
  __pyx_t_14GatSegmentList_Position bucket_size;
  __pyx_t_14GatSegmentList_Position nbuckets;
  __pyx_t_14GatSegmentList_Position total_size;
};


/* "GatEngine.pyx":1388
 *         return annotations.overlapWithSegments( segments )
 * 
 * cdef class CounterNucleotideDensity(Counter):             # <<<<<<<<<<<<<<
 *     name = "nucleotide-density"
 * 
 */
struct __pyx_obj_9GatEngine_CounterNucleotideDensity {
  struct __pyx_obj_9GatEngine_Counter __pyx_base;
};


/* "GatEngine.pyx":321
 *             self.cdf = NULL
 * 
 * cdef class HistogramSamplerSlow:             # <<<<<<<<<<<<<<
 * 
 *     cdef numpy.ndarray cdf
 */
struct __pyx_obj_9GatEngine_HistogramSamplerSlow {
  PyObject_HEAD
  struct __pyx_vtabstruct_9GatEngine_HistogramSamplerSlow *__pyx_vtab;
  PyArrayObject *cdf;
  __pyx_t_14GatSegmentList_Position bucket_size;
};



/* "GatSegmentList.pxd":150
 * ## definition of segmentlist
 * #####################################################
 * cdef class SegmentList:             # <<<<<<<<<<<<<<
 * 
 *     cdef Segment * segments
 */

struct __pyx_vtabstruct_14GatSegmentList_SegmentList {
  PyObject *(*share)(struct __pyx_obj_14GatSegmentList_SegmentList *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*sort)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*extend)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  PyObject *(*add)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
  PyObject *(*trim_ends)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, int, int __pyx_skip_dispatch);
  PyObject *(*trim)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
  PyObject *(*normalize)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  PyObject *(*merge)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_PositionDifference, int __pyx_skip_dispatch);
  PyObject *(*check)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*getRandomPosition)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*overlapWithRange)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*getOverlappingSegmentsWithRange)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*overlapWithSegments)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*intersectionWithSegments)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch, struct __pyx_opt_args_14GatSegmentList_11SegmentList_intersectionWithSegments *__pyx_optional_args);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*getFilledSegmentsFromStart)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_PositionDifference, int __pyx_skip_dispatch);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*getFilledSegmentsFromEnd)(struct __pyx_obj_14GatSegmentList_SegmentList *, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_PositionDifference, int __pyx_skip_dispatch);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*filter)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*intersect)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*subtract)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  PyObject *(*extend_segments)(struct __pyx_obj_14GatSegmentList_SegmentList *, int, int __pyx_skip_dispatch);
  PyObject *(*expand_segments)(struct __pyx_obj_14GatSegmentList_SegmentList *, double, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*sum)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*max)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  __pyx_t_14GatSegmentList_Position (*min)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  PyObject *(*clear)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  PyObject *(*summarize)(struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
  PyObject *(*_add)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_t_14GatSegmentList_Segment);
  PyObject *(*_resize)(struct __pyx_obj_14GatSegmentList_SegmentList *, int);
  PyObject *(*insert)(struct __pyx_obj_14GatSegmentList_SegmentList *, int, struct __pyx_t_14GatSegmentList_Segment);
  int (*_getInsertionPoint)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_t_14GatSegmentList_Segment);
  __pyx_t_14GatSegmentList_Position (*overlap)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_t_14GatSegmentList_Segment);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*getOverlappingSegments)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_t_14GatSegmentList_Segment);
  struct __pyx_obj_14GatSegmentList_SegmentList *(*truncate)(struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_t_14GatSegmentList_Segment);
  off_t (*toMMAP)(struct __pyx_obj_14GatSegmentList_SegmentList *, void *, int, off_t);
  void (*fromMMAP)(struct __pyx_obj_14GatSegmentList_SegmentList *);
};
static struct __pyx_vtabstruct_14GatSegmentList_SegmentList *__pyx_vtabptr_14GatSegmentList_SegmentList;


/* "GatEngine.pyx":2154
 * ## Quick parsing of tabular files (bed, gff)
 * ############################################################
 * cdef class TupleProxy:             # <<<<<<<<<<<<<<
 *     '''Proxy class for access to parsed row as a tuple.
 * 
 */

struct __pyx_vtabstruct_9GatEngine_TupleProxy {
  PyObject *(*take)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t);
  PyObject *(*present)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t);
  PyObject *(*copy)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t);
  PyObject *(*update)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t);
};
static struct __pyx_vtabstruct_9GatEngine_TupleProxy *__pyx_vtabptr_9GatEngine_TupleProxy;


/* "GatEngine.pyx":214
 *             self.cdf = NULL
 * 
 * cdef class SegmentListSampler:             # <<<<<<<<<<<<<<
 *     '''return a new position within segment list.
 * 
 */

struct __pyx_vtabstruct_9GatEngine_SegmentListSampler {
  PyObject *(*sample)(struct __pyx_obj_9GatEngine_SegmentListSampler *, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *__pyx_vtabptr_9GatEngine_SegmentListSampler;


/* "GatEngine.pyx":1198
 * ########################################################
 * ########################################################
 * cdef class SamplerGlobalPermutation(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     Sample segments by global permutation.
 */

struct __pyx_vtabstruct_9GatEngine_SamplerGlobalPermutation {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerGlobalPermutation *__pyx_vtabptr_9GatEngine_SamplerGlobalPermutation;


/* "GatEngine.pyx":143
 *         return pos, overlap
 * 
 * cdef class SegmentListSamplerWithEdgeEffects:             # <<<<<<<<<<<<<<
 * 
 *     cdef SegmentList segment_list
 */

struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerWithEdgeEffects {
  PyObject *(*sample)(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_vtabptr_9GatEngine_SegmentListSamplerWithEdgeEffects;


/* "GatEngine.pyx":411
 *     pass
 * 
 * cdef class SamplerAnnotator(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     sample with the annotator method.
 */

struct __pyx_vtabstruct_9GatEngine_SamplerAnnotator {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerAnnotator *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerAnnotator *__pyx_vtabptr_9GatEngine_SamplerAnnotator;


/* "GatEngine.pyx":1081
 * ########################################################
 * ########################################################
 * cdef class SamplerLocalPermutation(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     Sample segments by local permutation.
 */

struct __pyx_vtabstruct_9GatEngine_SamplerLocalPermutation {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerLocalPermutation *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerLocalPermutation *__pyx_vtabptr_9GatEngine_SamplerLocalPermutation;


/* "GatEngine.pyx":1355
 * ########################################################
 * ########################################################
 * cdef class SamplerDummy(Sampler):             # <<<<<<<<<<<<<<
 * 
 *     def __init__( self ):
 */

struct __pyx_vtabstruct_9GatEngine_SamplerDummy {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerDummy *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerDummy *__pyx_vtabptr_9GatEngine_SamplerDummy;


/* "GatEngine.pyx":842
 * ########################################################
 * ########################################################
 * cdef class SamplerUniform(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     For debugging purposes.
 */

struct __pyx_vtabstruct_9GatEngine_SamplerUniform {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerUniform *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerUniform *__pyx_vtabptr_9GatEngine_SamplerUniform;


/* "GatEngine.pyx":962
 * ########################################################
 * ########################################################
 * cdef class SamplerShift(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     Sample segments by shifting them by a random amount within *radius*
 */

struct __pyx_vtabstruct_9GatEngine_SamplerShift {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerShift *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerShift *__pyx_vtabptr_9GatEngine_SamplerShift;


/* "GatEngine.pyx":617
 * ########################################################
 * ########################################################
 * cdef class SamplerSegments(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     sample *n* segments from segment length distribution.
 */

struct __pyx_vtabstruct_9GatEngine_SamplerSegments {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerSegments *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerSegments *__pyx_vtabptr_9GatEngine_SamplerSegments;


/* "GatEngine.pyx":321
 *             self.cdf = NULL
 * 
 * cdef class HistogramSamplerSlow:             # <<<<<<<<<<<<<<
 * 
 *     cdef numpy.ndarray cdf
 */

struct __pyx_vtabstruct_9GatEngine_HistogramSamplerSlow {
  __pyx_t_14GatSegmentList_Position (*sample)(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_HistogramSamplerSlow *__pyx_vtabptr_9GatEngine_HistogramSamplerSlow;


/* "GatEngine.pyx":353
 *         return base
 * 
 * cdef class HistogramSampler:             # <<<<<<<<<<<<<<
 * 
 *     cdef Position * cdf
 */

struct __pyx_vtabstruct_9GatEngine_HistogramSampler {
  __pyx_t_14GatSegmentList_Position (*sample)(struct __pyx_obj_9GatEngine_HistogramSampler *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_HistogramSampler *__pyx_vtabptr_9GatEngine_HistogramSampler;


/* "GatEngine.pyx":104
 *     return (da > db) - (da < db)
 * 
 * cdef class SegmentListSamplerSlow:             # <<<<<<<<<<<<<<
 * 
 *     cdef SegmentList segment_list
 */

struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerSlow {
  PyObject *(*sample)(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerSlow *__pyx_vtabptr_9GatEngine_SegmentListSamplerSlow;


/* "GatEngine.pyx":709
 * ########################################################
 * ########################################################
 * cdef class SamplerBruteForce(Sampler):             # <<<<<<<<<<<<<<
 *     '''
 *     sample segments from length distribution until
 */

struct __pyx_vtabstruct_9GatEngine_SamplerBruteForce {
  struct __pyx_obj_14GatSegmentList_SegmentList *(*sample)(struct __pyx_obj_9GatEngine_SamplerBruteForce *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9GatEngine_SamplerBruteForce *__pyx_vtabptr_9GatEngine_SamplerBruteForce;


/* "GatEngine.pyx":2284
 *         return self.fields[self.index-1]
 * 
 * cdef class BedProxy( TupleProxy ):             # <<<<<<<<<<<<<<
 * 
 *    cdef track
 */

struct __pyx_vtabstruct_9GatEngine_BedProxy {
  struct __pyx_vtabstruct_9GatEngine_TupleProxy __pyx_base;
};
static struct __pyx_vtabstruct_9GatEngine_BedProxy *__pyx_vtabptr_9GatEngine_BedProxy;
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
        PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
        PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {  /* inlined PySequence_GetItem() */
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (unlikely(l < 0)) return NULL;
                i += l;
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static CYTHON_INLINE int  __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);

#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t); /* proto */

#define UNARY_NEG_WOULD_OVERFLOW(x)            (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

static CYTHON_INLINE long __Pyx_mod_long(long, long); /* proto */

static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */

static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj) \
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \
 likely(PyInt_CheckExact(obj)) ? \
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {  /* inlined PySequence_SetItem() */
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (unlikely(l < 0)) return -1;
                i += l;
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (PySequence_Check(o) && !PyDict_Check(o)) {
#else
    if (PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        PyObject *m;
        m = __Pyx_GetAttrString(d, "get");
        if (!m) return NULL;
        value = PyObject_CallFunctionObjArgs(m, key,
                                             (default_value == Py_None) ? NULL : default_value, NULL);
        Py_DECREF(m);
    }
#endif
    return value;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(PyList_Append(L, x) < 0)) return NULL;
        Py_INCREF(Py_None);
        return Py_None; /* this is just to have an accurate signature */
    } else {
        PyObject *r, *m;
        m = __Pyx_GetAttrString(L, "append");
        if (!m) return NULL;
        r = PyObject_CallFunctionObjArgs(m, x, NULL);
        Py_DECREF(m);
        return r;
    }
}

static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred())
            PyErr_SetObject(PyExc_KeyError, key);
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/

static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
                                             int is_tuple, int has_known_size, int decref_tuple);

static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

static CYTHON_INLINE int __Pyx_PySequence_Contains(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

#if PY_VERSION_HEX < 0x02050000
#ifndef PyAnySet_CheckExact
#define PyAnySet_CheckExact(ob) \
    ((ob)->ob_type == &PySet_Type || \
     (ob)->ob_type == &PyFrozenSet_Type)
#define PySet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
#define Pyx_PyFrozenSet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
#define PySet_Size(anyset) \
    PyObject_Size((anyset))
#define PySet_Contains(anyset, key) \
    PySequence_Contains((anyset), (key))
#define PySet_Pop(set) \
    PyObject_CallMethod(set, (char *)"pop", NULL)
static CYTHON_INLINE int PySet_Clear(PyObject *set) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
#endif /* PyAnySet_CheckExact (<= Py2.4) */
#endif /* < Py2.5  */

static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);

static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif


  static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname); /*proto*/

#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f) \
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f) \
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f) \
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
    int flags;
    PyObject *func_dict;
    PyObject *func_weakreflist;
    PyObject *func_name;
    PyObject *func_doc;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj; /* No-args super() class cell */
    void *defaults;
    int defaults_pyobjects;
    PyObject *defaults_tuple; /* Const defaults tuple */
    PyObject *(*defaults_getter)(PyObject *);
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, self, module, code) \
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, self, module, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *,
                                      PyMethodDef *ml, int flags,
                                      PyObject *self, PyObject *module,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static int __Pyx_CyFunction_init(void);

struct __pyx_t_14GatSegmentList_Segment;
  static PyObject* __pyx_convert__to_py___pyx_t_14GatSegmentList_Segment(struct __pyx_t_14GatSegmentList_Segment s);
  static CYTHON_INLINE off_t __Pyx_PyInt_from_py_off_t(PyObject *);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_off_t(off_t);

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
    #define __Pyx_c_difff(a, b) ((a)-(b))
    #define __Pyx_c_prodf(a, b) ((a)*(b))
    #define __Pyx_c_quotf(a, b) ((a)/(b))
    #define __Pyx_c_negf(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
    #define __Pyx_c_conjf(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_absf(z)     (::std::abs(z))
        #define __Pyx_c_powf(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zerof(z) ((z)==0)
    #define __Pyx_c_conjf(z)    (conjf(z))
    #if 1
        #define __Pyx_c_absf(z)     (cabsf(z))
        #define __Pyx_c_powf(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq(a, b)   ((a)==(b))
    #define __Pyx_c_sum(a, b)  ((a)+(b))
    #define __Pyx_c_diff(a, b) ((a)-(b))
    #define __Pyx_c_prod(a, b) ((a)*(b))
    #define __Pyx_c_quot(a, b) ((a)/(b))
    #define __Pyx_c_neg(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
    #define __Pyx_c_conj(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (::std::abs(z))
        #define __Pyx_c_pow(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero(z) ((z)==0)
    #define __Pyx_c_conj(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (cabs(z))
        #define __Pyx_c_pow(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

#define __Pyx_Generator_USED
#include <structmember.h>
#include <frameobject.h>
typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *);
typedef struct {
    PyObject_HEAD
    __pyx_generator_body_t body;
    PyObject *closure;
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    int resume_label;
    char is_running;  // using T_BOOL for property below requires char value
} __pyx_GeneratorObject;
static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
                                                  PyObject *closure);
static int __pyx_Generator_init(void);
static int __Pyx_Generator_clear(PyObject* self);
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
#endif

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static void* __Pyx_GetVtable(PyObject *dict); /*proto*/

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/


/* Module declarations from '__builtin__' */

/* Module declarations from 'cython' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'GatSegmentList' */
static PyTypeObject *__pyx_ptype_14GatSegmentList_file = 0;
static PyTypeObject *__pyx_ptype_14GatSegmentList_SegmentList = 0;

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/

/* Module declarations from 'GatEngine' */
static PyTypeObject *__pyx_ptype_9GatEngine_file = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_IntervalContainer = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_IntervalDictionary = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_IntervalCollection = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SegmentListSamplerSlow = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SegmentListSamplerWithEdgeEffects = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SegmentListSampler = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_HistogramSamplerSlow = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_HistogramSampler = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_Sampler = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerAnnotator = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerSegments = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerBruteForce = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerUniform = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerShift = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerLocalPermutation = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerGlobalPermutation = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplerDummy = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_Counter = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_CounterNucleotideOverlap = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_CounterNucleotideDensity = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_CounterSegmentOverlap = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_CounterSegmentMidpointOverlap = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_CounterAnnotationOverlap = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_CounterAnnotationMidpointOverlap = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_AnnotatorResult = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_AnnotatorResultExtended = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_TupleProxy = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_BedProxy = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_Samples = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplesFile = 0;
static PyTypeObject *__pyx_ptype_9GatEngine_SamplesCached = 0;
static PyTypeObject *__pyx_ptype_9GatEngine___pyx_scope_struct____str__ = 0;
static PyTypeObject *__pyx_ptype_9GatEngine___pyx_scope_struct_1_getSegmentLists = 0;
static PyTypeObject *__pyx_ptype_9GatEngine___pyx_scope_struct_2_getSegmentLists = 0;
static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_lmin(__pyx_t_14GatSegmentList_PositionDifference, __pyx_t_14GatSegmentList_PositionDifference); /*proto*/
static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_lmax(__pyx_t_14GatSegmentList_PositionDifference, __pyx_t_14GatSegmentList_PositionDifference); /*proto*/
static CYTHON_INLINE double __pyx_f_9GatEngine_dmin(double, double); /*proto*/
static CYTHON_INLINE double __pyx_f_9GatEngine_dmax(double, double); /*proto*/
static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_range_overlap(__pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position); /*proto*/
static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_segment_length(struct __pyx_t_14GatSegmentList_Segment); /*proto*/
static int __pyx_f_9GatEngine_cmpPosition(const void*, const void*); /*proto*/
static int __pyx_f_9GatEngine_cmpDouble(const void*, const void*); /*proto*/
static PyObject *__pyx_f_9GatEngine_getNPTwoSidedPValue(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static double __pyx_f_9GatEngine_getTwoSidedPValue(__pyx_t_9GatEngine_EnrichmentStatistics *, double); /*proto*/
static __pyx_t_9GatEngine_EnrichmentStatistics *__pyx_f_9GatEngine_makeEnrichmentStatistics(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static double __pyx_f_9GatEngine_computeFalsePositiveRate(__pyx_t_9GatEngine_EnrichmentStatistics **, __pyx_t_14GatSegmentList_Position, __pyx_t_14GatSegmentList_Position, double); /*proto*/
static PyObject *__pyx_f_9GatEngine_computeFDR(PyObject *, int __pyx_skip_dispatch); /*proto*/
static CYTHON_INLINE int __pyx_f_9GatEngine_isSampleSignificantAtPvalue(__pyx_t_9GatEngine_EnrichmentStatistics *, __pyx_t_14GatSegmentList_Position, double); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_9GatEngine_DTYPE_INT_t = { "DTYPE_INT_t", NULL, sizeof(__pyx_t_9GatEngine_DTYPE_INT_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_9GatEngine_DTYPE_INT_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_9GatEngine_DTYPE_INT_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_9GatEngine_DTYPE_FLOAT_t = { "DTYPE_FLOAT_t", NULL, sizeof(__pyx_t_9GatEngine_DTYPE_FLOAT_t), { 0 }, 0, 'R', 0, 0 };
#define __Pyx_MODULE_NAME "GatEngine"
int __pyx_module_is_main_GatEngine = 0;

/* Implementation of 'GatEngine' */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_xrange;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_OSError;
static PyObject *__pyx_builtin_RuntimeError;
static int __pyx_pf_9GatEngine_22SegmentListSamplerSlow___init__(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list); /* proto */
static PyObject *__pyx_pf_9GatEngine_22SegmentListSamplerSlow_2sample(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_length); /* proto */
static int __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects___init__(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list); /* proto */
static PyObject *__pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects_2sample(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_length); /* proto */
static void __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects_4__dealloc__(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_18SegmentListSampler___init__(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list); /* proto */
static PyObject *__pyx_pf_9GatEngine_18SegmentListSampler_2sample(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_sample_length); /* proto */
static void __pyx_pf_9GatEngine_18SegmentListSampler_4__dealloc__(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_20HistogramSamplerSlow___init__(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *__pyx_v_self, PyArrayObject *__pyx_v_histogram, __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size); /* proto */
static PyObject *__pyx_pf_9GatEngine_20HistogramSamplerSlow_2sample(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_16HistogramSampler___init__(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self, PyArrayObject *__pyx_v_histogram, __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size); /* proto */
static PyObject *__pyx_pf_9GatEngine_16HistogramSampler_2sample(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self); /* proto */
static void __pyx_pf_9GatEngine_16HistogramSampler_4__dealloc__(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_16SamplerAnnotator___init__(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets, PyObject *__pyx_v_nunsuccessful_rounds); /* proto */
static PyObject *__pyx_pf_9GatEngine_16SamplerAnnotator_2__reduce__(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_16SamplerAnnotator_4sample(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_buildSamplerAnnotator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_15SamplerSegments___init__(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets); /* proto */
static PyObject *__pyx_pf_9GatEngine_15SamplerSegments_2__reduce__(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15SamplerSegments_4sample(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_2buildSamplerSegments(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_17SamplerBruteForce___init__(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets, PyObject *__pyx_v_ntries_inner, PyObject *__pyx_v_ntries_outer); /* proto */
static PyObject *__pyx_pf_9GatEngine_17SamplerBruteForce_2__reduce__(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17SamplerBruteForce_4sample(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_4buildSamplerBruteForce(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_14SamplerUniform___init__(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self, PyObject *__pyx_v_increment, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets, PyObject *__pyx_v_current_orientation, PyObject *__pyx_v_current_workspace, PyObject *__pyx_v_current_position); /* proto */
static PyObject *__pyx_pf_9GatEngine_14SamplerUniform_2__reduce__(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_14SamplerUniform_4sample(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_6buildSamplerUniform(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_12SamplerShift___init__(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self, PyObject *__pyx_v_radius, PyObject *__pyx_v_extension); /* proto */
static PyObject *__pyx_pf_9GatEngine_12SamplerShift_2__reduce__(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_12SamplerShift_4sample(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_8buildSamplerShift(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_23SamplerLocalPermutation___init__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerLocalPermutation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_23SamplerLocalPermutation_2sample(struct __pyx_obj_9GatEngine_SamplerLocalPermutation *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static int __pyx_pf_9GatEngine_24SamplerGlobalPermutation___init__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_24SamplerGlobalPermutation_2sample(struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static int __pyx_pf_9GatEngine_12SamplerDummy___init__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerDummy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_12SamplerDummy_2sample(struct __pyx_obj_9GatEngine_SamplerDummy *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_24CounterNucleotideOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterNucleotideOverlap *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_annotations, CYTHON_UNUSED struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_24CounterNucleotideDensity___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterNucleotideDensity *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_annotations, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_21CounterSegmentOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterSegmentOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_29CounterSegmentMidpointOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterSegmentMidpointOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_24CounterAnnotationOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterAnnotationOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_32CounterAnnotationMidpointOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterAnnotationMidpointOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_10getNPTwoSidedPValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ar, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_9GatEngine_12getNPTwoSidedPValueFast(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ar, double __pyx_v_val, double __pyx_v_mean); /* proto */
static int __pyx_pf_9GatEngine_15AnnotatorResult___init__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_annotation, PyObject *__pyx_v_counter, PyObject *__pyx_v_observed, PyObject *__pyx_v_samples, PyObject *__pyx_v_reference, PyObject *__pyx_v_pseudo_count); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_2__str__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static void __pyx_pf_9GatEngine_15AnnotatorResult_4__dealloc__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_5track___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_10annotation___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_7counter___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8observed___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8expected___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_4fold___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6stddev___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6pvalue___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_15AnnotatorResult_6pvalue_2__set__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6qvalue___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_15AnnotatorResult_6qvalue_2__set__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8nsamples___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_7samples___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_15AnnotatorResult_15format_observed___set__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6isSampleSignificantAtPvalue(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_sample_id, double __pyx_v_pvalue); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8getSample(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_sample_id); /* proto */
static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_10getEmpiricalPValue(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9GatEngine_23AnnotatorResultExtended___init__(struct __pyx_obj_9GatEngine_AnnotatorResultExtended *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_annotation, PyObject *__pyx_v_counter, PyObject *__pyx_v_observed, PyObject *__pyx_v_samples, PyObject *__pyx_v_track_segments, PyObject *__pyx_v_annotation_segments, PyObject *__pyx_v_workspace, PyObject *__pyx_v_reference, PyObject *__pyx_v_pseudo_count); /* proto */
static PyObject *__pyx_pf_9GatEngine_23AnnotatorResultExtended_7__str____toFold(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b); /* proto */
static PyObject *__pyx_pf_9GatEngine_23AnnotatorResultExtended_7__str___2_toDensity(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b); /* proto */
static PyObject *__pyx_pf_9GatEngine_23AnnotatorResultExtended_2__str__(struct __pyx_obj_9GatEngine_AnnotatorResultExtended *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_14getNormedPValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value, PyObject *__pyx_v_r); /* proto */
static PyObject *__pyx_pf_9GatEngine_16getEmpiricalPValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value, PyObject *__pyx_v_r); /* proto */
static PyObject *__pyx_pf_9GatEngine_18updatePValues(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_annotator_results, PyObject *__pyx_v_method); /* proto */
static PyObject *__pyx_pf_9GatEngine_20getQValues(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pvalues, PyObject *__pyx_v_method, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9GatEngine_22updateQValues(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_annotator_results, PyObject *__pyx_v_method, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9GatEngine_22UnconditionalWorkspace___call__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_22UnconditionalWorkspace_2filter(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_31ConditionalWorkspaceCooccurance___call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_28ConditionalWorkspaceCentered___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_extension, PyObject *__pyx_v_expansion); /* proto */
static PyObject *__pyx_pf_9GatEngine_28ConditionalWorkspaceCentered_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace); /* proto */
static PyObject *__pyx_pf_9GatEngine_38ConditionalWorkspaceAnnotationCentered_getCenter(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations); /* proto */
static PyObject *__pyx_pf_9GatEngine_35ConditionalWorkspaceSegmentCentered_getCenter(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_segments, CYTHON_UNUSED PyObject *__pyx_v_annotations); /* proto */
static PyObject *__pyx_pf_9GatEngine_24_append(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_counts, CYTHON_UNUSED PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_z); /* proto */
static PyObject *__pyx_pf_9GatEngine_26_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_counts, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_z); /* proto */
static PyObject *__pyx_pf_9GatEngine_28_defdictfloat(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_30computeCounts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_counter, PyObject *__pyx_v_aggregator, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace, PyObject *__pyx_v_workspace_generator, PyObject *__pyx_v_append); /* proto */
static int __pyx_pf_9GatEngine_10TupleProxy___cinit__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_10TupleProxy_2__getitem__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static Py_ssize_t __pyx_pf_9GatEngine_10TupleProxy_4__len__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self); /* proto */
static void __pyx_pf_9GatEngine_10TupleProxy_6__dealloc__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_10TupleProxy_8__iter__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_10TupleProxy_10__next__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_8BedProxy___init__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self, PyObject *__pyx_v_track); /* proto */
static PyObject *__pyx_pf_9GatEngine_8BedProxy_6contig___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_8BedProxy_5start___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_8BedProxy_3end___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_8BedProxy_4name___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_8BedProxy_5track___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_5Track___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_line); /* proto */
static PyObject *__pyx_pf_9GatEngine_5Track_2__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_5Track_4__getitem__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_9GatEngine_5Track_6__setitem__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_9GatEngine_12tsv_iterator___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_infile); /* proto */
static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_4preparse(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_line); /* proto */
static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_6create(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_8next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_12bed_iterator___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_infile); /* proto */
static PyObject *__pyx_pf_9GatEngine_12bed_iterator_2preparse(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_line); /* proto */
static PyObject *__pyx_pf_9GatEngine_12bed_iterator_4create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_32_genie(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_34readFromBed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filenames, PyObject *__pyx_v_allow_multiple); /* proto */
static int __pyx_pf_9GatEngine_17IntervalContainer___init__(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_2getName(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_4setName(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_6_getSharedMemoryName(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_8share(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_filename); /* proto */
static void __pyx_pf_9GatEngine_17IntervalContainer_10__dealloc__(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_12unshare(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_14sum(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_16counts(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_18sort(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_20extend(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_extension); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_22expand(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_expansion); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_24normalize(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_26check(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_18IntervalDictionary___init__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_unreduce); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_2__reduce__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_4getSegmentLists(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_7intersect(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_9truncate(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static Py_ssize_t __pyx_pf_9GatEngine_18IntervalDictionary_11__len__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_13__str__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_18IntervalDictionary_15__delitem__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_17keys(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_19add(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_segmentlist); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_21items(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_23__getitem__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_9GatEngine_18IntervalDictionary_25__setitem__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_val); /* proto */
static int __pyx_pf_9GatEngine_18IntervalDictionary_27__contains__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_29iteritems(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_31clone(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_33filter(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_35toIsochores(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_isochores, PyObject *__pyx_v_truncate); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_37fromIsochores(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_36buildIntervalDictionary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_18IntervalCollection___init__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_unreduce); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_2__reduce__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_4getSegmentLists(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_7load(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_filenames, PyObject *__pyx_v_split_tracks); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_9save(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_outfile, PyObject *__pyx_v_prefix, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_11normalize(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_13outputStats(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_outfile); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_15merge(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_delete); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_17collapse(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_19countsPerTrack(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_21intersect(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_23filter(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_25restrict(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_restrict); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_27toIsochores(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_isochores, PyObject *__pyx_v_truncate); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_29fromIsochores(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_31clone(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_33tracks(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_9GatEngine_18IntervalCollection_35__len__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_18IntervalCollection_37__delitem__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_39keys(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_41add(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_contig, PyObject *__pyx_v_segmentlist); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_43__getitem__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_9GatEngine_18IntervalCollection_45__contains__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_47__str__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_49iteritems(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_51outputOverlapStats(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_outfile, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9GatEngine_38buildIntervalCollection(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static int __pyx_pf_9GatEngine_7Samples___init__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_7Samples_2add(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore, PyObject *__pyx_v_segmentlist); /* proto */
static PyObject *__pyx_pf_9GatEngine_7Samples_4hasSample(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore); /* proto */
static int __pyx_pf_9GatEngine_7Samples_6__contains__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track); /* proto */
static PyObject *__pyx_pf_9GatEngine_7Samples_8__getitem__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track); /* proto */
static PyObject *__pyx_pf_9GatEngine_7Samples_10load(CYTHON_UNUSED struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_track, CYTHON_UNUSED PyObject *__pyx_v_sample_id, CYTHON_UNUSED PyObject *__pyx_v_isochore); /* proto */
static int __pyx_pf_9GatEngine_7Samples_12__delitem__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static Py_ssize_t __pyx_pf_9GatEngine_7Samples_14__len__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self); /* proto */
static int __pyx_pf_9GatEngine_11SamplesFile___init__(struct __pyx_obj_9GatEngine_SamplesFile *__pyx_v_self, PyObject *__pyx_v_filenames, PyObject *__pyx_v_regex); /* proto */
static PyObject *__pyx_pf_9GatEngine_11SamplesFile_2load(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplesFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_track, CYTHON_UNUSED PyObject *__pyx_v_sample_id, CYTHON_UNUSED PyObject *__pyx_v_isochore); /* proto */
static int __pyx_pf_9GatEngine_13SamplesCached___init__(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_9GatEngine_13SamplesCached_2loadIndex(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_13SamplesCached_4add(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore, PyObject *__pyx_v_segmentlist); /* proto */
static PyObject *__pyx_pf_9GatEngine_13SamplesCached_6toKey(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore); /* proto */
static PyObject *__pyx_pf_9GatEngine_13SamplesCached_8hasSample(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore); /* proto */
static void __pyx_pf_9GatEngine_13SamplesCached_10__dealloc__(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9GatEngine_13SamplesCached_12load(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore); /* proto */
static PyObject *__pyx_pf_9GatEngine_40computeFDR(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_annotator_results); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static char __pyx_k_1[] = "sampling from empty segment list";
static char __pyx_k_2[] = "sample %i does not overlap with workspace: offset=%i, r=%i, index=%i/%i";
static char __pyx_k_3[] = "out of memory when allocation %i bytes";
static char __pyx_k_4[] = "sample %i-%i does not overlap with workspace: offset=%i, rpos=%i, rseg=%i, index=%i/%i, segment=%s";
static char __pyx_k_5[] = "range error for %i: %i >= %i";
static char __pyx_k_6[] = "sample %i-%i does not overlap with workspace: rpos=%i, rseg=%i, index=%i/%i, segment=%s";
static char __pyx_k_7[] = "sampling from empty histogram";
static char __pyx_k_9[] = "nunsuccessful_rounds";
static char __pyx_k_10[] = "buildSamplerAnnotator";
static char __pyx_k_11[] = "segment list is not normalized";
static char __pyx_k_12[] = "workspace is not normalized";
static char __pyx_k_13[] = "getLengthDistribution";
static char __pyx_k_15[] = "buildSamplerSegments";
static char __pyx_k_16[] = "buildSamplerBruteForce";
static char __pyx_k_17[] = "sampling did not converge: %s";
static char __pyx_k_19[] = "start=%i, points[-1]=%i, work_end=%i";
static char __pyx_k_20[] = "intersectionWithSegments";
static char __pyx_k_21[] = "not enough samples - no stats in makeEnrichmentStatistics";
static char __pyx_k_23[] = "0 fold change not applicable";
static char __pyx_k_26[] = "%i";
static char __pyx_k_27[] = "-inf";
static char __pyx_k_28[] = "\t";
static char __pyx_k_32[] = "/ifs/devel/gat/GatEngine/GatEngine.pyx";
static char __pyx_k_35[] = "scipy required";
static char __pyx_k_37[] = "unknown method '%s'";
static char __pyx_k_38[] = "qvalue computation failed: %s";
static char __pyx_k_39[] = "need to specify either expansion or extension";
static char __pyx_k_42[] = "incomplete line at %s: %s";
static char __pyx_k_43[] = "row too large - more than %i fields";
static char __pyx_k_44[] = "not enough fields, expected >%i, got %i";
static char __pyx_k_45[] = "list index out of range";
static char __pyx_k_47[] = "([^\\s=]+) *= *(\"[^\"]*\"|[^ ]*)";
static char __pyx_k_49[] = "\"";
static char __pyx_k_50[] = "incomplete line at %s";
static char __pyx_k_53[] = "track without field 'name' in file '%s'";
static char __pyx_k_54[] = "track '%s' in multiple filenames: %s and %s";
static char __pyx_k_55[] = "malformatted entry in line %s:%i, msg=%s";
static char __pyx_k_56[] = "IntervalContainer: tried to build shared memory name without name defined";
static char __pyx_k_57[] = "/";
static char __pyx_k_59[] = "_getSharedMemoryName";
static char __pyx_k_61[] = "could not create shared memory at %s; ERRNO=%i";
static char __pyx_k_62[] = "could not resize memory at %s; ERRNO=%i";
static char __pyx_k_63[] = "could not create memory mapped file";
static char __pyx_k_65[] = "IntervalCollection.__dealloc__(): could not unlink shared memory %s: ERRNO=%i";
static char __pyx_k_66[] = "IntervalCollection.__dealloc__(): freeing shared memory at %s";
static char __pyx_k_67[] = "unsharing shared IntervalCollection";
static char __pyx_k_68[] = "IntervalCollection.unshare(): could not unlink shared memory %s: ERRNO=%i";
static char __pyx_k_69[] = "IntervalCollection.unshare(): freeing shared memory at %s";
static char __pyx_k_70[] = "buildIntervalDictionary";
static char __pyx_k_71[] = ";";
static char __pyx_k_72[] = "%s:%i,%i";
static char __pyx_k_74[] = "%s.%s";
static char __pyx_k_75[] = ".";
static char __pyx_k_78[] = "buildIntervalCollection";
static char __pyx_k_80[] = "";
static char __pyx_k_81[] = "track name=%s%s %s\n";
static char __pyx_k_82[] = " ";
static char __pyx_k_83[] = "%s=%s";
static char __pyx_k_84[] = "%s\t%i\t%i\n";
static char __pyx_k_85[] = "section\ttrack\tcontig\tnsegments\tlength\n";
static char __pyx_k_87[] = "\n";
static char __pyx_k_90[] = "%s:%s";
static char __pyx_k_91[] = ",";
static char __pyx_k_92[] = "section\ttrack\tcontig\toverlap\tlength\tdensity\n";
static char __pyx_k_94[] = "%f";
static char __pyx_k_95[] = "loading called for uncached data";
static char __pyx_k_97[] = "releasing memory for sample %s";
static char __pyx_k_98[] = ".idx";
static char __pyx_k_99[] = "loading index from %s";
static char __pyx_k__B[] = "B";
static char __pyx_k__E[] = "E";
static char __pyx_k__H[] = "H";
static char __pyx_k__I[] = "I";
static char __pyx_k__L[] = "L";
static char __pyx_k__O[] = "O";
static char __pyx_k__Q[] = "Q";
static char __pyx_k___[] = "_";
static char __pyx_k__a[] = "a";
static char __pyx_k__b[] = "b";
static char __pyx_k__d[] = "d";
static char __pyx_k__f[] = "f";
static char __pyx_k__g[] = "g";
static char __pyx_k__h[] = "h";
static char __pyx_k__i[] = "i";
static char __pyx_k__k[] = "k";
static char __pyx_k__l[] = "l";
static char __pyx_k__q[] = "q";
static char __pyx_k__r[] = "r";
static char __pyx_k__v[] = "v";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__z[] = "z";
static char __pyx_k_100[] = "loaded index from %s: %i items";
static char __pyx_k_101[] = "%s-%s-%s";
static char __pyx_k_102[] = "progress: %i/%i ";
static char __pyx_k_103[] = "ndarray is not C contiguous";
static char __pyx_k_105[] = "ndarray is not Fortran contiguous";
static char __pyx_k_107[] = "Non-native byte order not supported";
static char __pyx_k_109[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_110[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_113[] = "Format string allocated too short.";
static char __pyx_k_115[] = "gat.IOTools";
static char __pyx_k_116[] = "*";
static char __pyx_k_117[] = "gat.Experiment";
static char __pyx_k_118[] = "gat.Stats";
static char __pyx_k_119[] = "scipy.stats";
static char __pyx_k_130[] = "nucleotide-overlap";
static char __pyx_k_131[] = "nucleotide-density";
static char __pyx_k_132[] = "segment-overlap";
static char __pyx_k_133[] = "segment-midoverlap";
static char __pyx_k_134[] = "annotation-overlap";
static char __pyx_k_135[] = "annotation-midoverlap";
static char __pyx_k_138[] = "getNPTwoSidedPValueFast";
static char __pyx_k_139[] = "%6.4f";
static char __pyx_k_140[] = "%6.4e";
static char __pyx_k_141[] = "annotation_nsegments";
static char __pyx_k_142[] = "percent_overlap_nsegments_track";
static char __pyx_k_143[] = "percent_overlap_size_track";
static char __pyx_k_144[] = "percent_overlap_nsegments_annotation";
static char __pyx_k_145[] = "percent_overlap_size_annotation";
static char __pyx_k_160[] = "compute a conditional workspace.\n\n    the default workspace is not conditional.";
static char __pyx_k_161[] = "UnconditionalWorkspace";
static char __pyx_k_164[] = "compute conditional workspace.\n\n    use only those parts of the workspace that contain both a segment\n    and an annotation.\n    ";
static char __pyx_k_165[] = "ConditionalWorkspaceCooccurance";
static char __pyx_k_171[] = "a workspace centered around segments/annotations.";
static char __pyx_k_172[] = "ConditionalWorkspaceCentered";
static char __pyx_k_175[] = "compute conditional workspace.\n\n    workspace is derived from the locations of the annotations.\n    ";
static char __pyx_k_176[] = "ConditionalWorkspaceAnnotationCentered";
static char __pyx_k_179[] = "compute conditional workspace.\n\n    workspace is derived from the locations of the segments\n    ";
static char __pyx_k_180[] = "ConditionalWorkspaceSegmentCentered";
static char __pyx_k_196[] = "bed track information.";
static char __pyx_k_207[] = "iterate over ``infile``.\n\n    Permits the use of file-like objects for example from the gzip module.\n    ";
static char __pyx_k__Zd[] = "Zd";
static char __pyx_k__Zf[] = "Zf";
static char __pyx_k__Zg[] = "Zg";
static char __pyx_k___d[] = "_d";
static char __pyx_k__ar[] = "ar";
static char __pyx_k__na[] = "na";
static char __pyx_k__os[] = "os";
static char __pyx_k__rb[] = "rb";
static char __pyx_k__re[] = "re";
static char __pyx_k__wb[] = "wb";
static char __pyx_k__add[] = "add";
static char __pyx_k__bed[] = "bed";
static char __pyx_k__cdf[] = "cdf";
static char __pyx_k__end[] = "end";
static char __pyx_k__fdr[] = "fdr";
static char __pyx_k__gat[] = "gat";
static char __pyx_k__int[] = "int";
static char __pyx_k__key[] = "key";
static char __pyx_k__log[] = "log";
static char __pyx_k__msg[] = "msg";
static char __pyx_k__std[] = "std";
static char __pyx_k__sum[] = "sum";
static char __pyx_k__val[] = "val";
static char __pyx_k__zip[] = "zip";
static char __pyx_k___set[] = "_set";
static char __pyx_k__args[] = "args";
static char __pyx_k__fold[] = "fold";
static char __pyx_k__join[] = "join";
static char __pyx_k__keys[] = "keys";
static char __pyx_k__line[] = "line";
static char __pyx_k__load[] = "load";
static char __pyx_k__math[] = "math";
static char __pyx_k__mean[] = "mean";
static char __pyx_k__mode[] = "mode";
static char __pyx_k__name[] = "name";
static char __pyx_k__next[] = "next";
static char __pyx_k__norm[] = "norm";
static char __pyx_k__path[] = "path";
static char __pyx_k__pval[] = "pval";
static char __pyx_k__segs[] = "segs";
static char __pyx_k__self[] = "self";
static char __pyx_k__sort[] = "sort";
static char __pyx_k__vals[] = "vals";
static char __pyx_k__warn[] = "warn";
static char __pyx_k__Stats[] = "Stats";
static char __pyx_k__Track[] = "Track";
static char __pyx_k___line[] = "_line";
static char __pyx_k__annos[] = "annos";
static char __pyx_k__array[] = "array";
static char __pyx_k__clone[] = "clone";
static char __pyx_k__debug[] = "debug";
static char __pyx_k__dtype[] = "dtype";
static char __pyx_k__float[] = "float";
static char __pyx_k__items[] = "items";
static char __pyx_k__merge[] = "merge";
static char __pyx_k__numpy[] = "numpy";
static char __pyx_k__other[] = "other";
static char __pyx_k__range[] = "range";
static char __pyx_k__regex[] = "regex";
static char __pyx_k__scipy[] = "scipy";
static char __pyx_k__split[] = "split";
static char __pyx_k__start[] = "start";
static char __pyx_k__stats[] = "stats";
static char __pyx_k__toKey[] = "toKey";
static char __pyx_k__total[] = "total";
static char __pyx_k__track[] = "track";
static char __pyx_k__types[] = "types";
static char __pyx_k__value[] = "value";
static char __pyx_k__write[] = "write";
static char __pyx_k__zeros[] = "zeros";
static char __pyx_k___genie[] = "_genie";
static char __pyx_k__absval[] = "absval";
static char __pyx_k__append[] = "append";
static char __pyx_k__arange[] = "arange";
static char __pyx_k__contig[] = "contig";
static char __pyx_k__counts[] = "counts";
static char __pyx_k__create[] = "create";
static char __pyx_k__cumsum[] = "cumsum";
static char __pyx_k__delete[] = "delete";
static char __pyx_k__exists[] = "exists";
static char __pyx_k__expand[] = "expand";
static char __pyx_k__extend[] = "extend";
static char __pyx_k__filter[] = "filter";
static char __pyx_k__getpid[] = "getpid";
static char __pyx_k__groups[] = "groups";
static char __pyx_k__infile[] = "infile";
static char __pyx_k__kwargs[] = "kwargs";
static char __pyx_k__l2fold[] = "l2fold";
static char __pyx_k__lineno[] = "lineno";
static char __pyx_k__merged[] = "merged";
static char __pyx_k__method[] = "method";
static char __pyx_k__nbytes[] = "nbytes";
static char __pyx_k__object[] = "object";
static char __pyx_k__prefix[] = "prefix";
static char __pyx_k__pvalue[] = "pvalue";
static char __pyx_k__qvalue[] = "qvalue";
static char __pyx_k__radius[] = "radius";
static char __pyx_k__random[] = "random";
static char __pyx_k__sample[] = "sample";
static char __pyx_k__search[] = "search";
static char __pyx_k__stddev[] = "stddev";
static char __pyx_k__storey[] = "storey";
static char __pyx_k__tracks[] = "tracks";
static char __pyx_k__values[] = "values";
static char __pyx_k__xrange[] = "xrange";
static char __pyx_k__CI95low[] = "CI95low";
static char __pyx_k__IOError[] = "IOError";
static char __pyx_k__IOTools[] = "IOTools";
static char __pyx_k__OSError[] = "OSError";
static char __pyx_k____str__[] = "__str__";
static char __pyx_k___append[] = "_append";
static char __pyx_k___toFold[] = "_toFold";
static char __pyx_k__argsort[] = "argsort";
static char __pyx_k__compile[] = "compile";
static char __pyx_k__counter[] = "counter";
static char __pyx_k__findall[] = "findall";
static char __pyx_k__headers[] = "headers";
static char __pyx_k__methodf[] = "methodf";
static char __pyx_k__outfile[] = "outfile";
static char __pyx_k__pvalues[] = "pvalues";
static char __pyx_k__qvalues[] = "qvalues";
static char __pyx_k__randint[] = "randint";
static char __pyx_k__samples[] = "samples";
static char __pyx_k__shuffle[] = "shuffle";
static char __pyx_k__vlambda[] = "vlambda";
static char __pyx_k__CI95high[] = "CI95high";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k____call__[] = "__call__";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____iter__[] = "__iter__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__allocate[] = "allocate";
static char __pyx_k__basename[] = "basename";
static char __pyx_k__expected[] = "expected";
static char __pyx_k__filename[] = "filename";
static char __pyx_k__isochore[] = "isochore";
static char __pyx_k__midpoint[] = "midpoint";
static char __pyx_k__min_pval[] = "min_pval";
static char __pyx_k__nbuckets[] = "nbuckets";
static char __pyx_k__nsamples[] = "nsamples";
static char __pyx_k__observed[] = "observed";
static char __pyx_k__openFile[] = "openFile";
static char __pyx_k__preparse[] = "preparse";
static char __pyx_k__property[] = "property";
static char __pyx_k__readline[] = "readline";
static char __pyx_k__segments[] = "segments";
static char __pyx_k__smoother[] = "smoother";
static char __pyx_k__truncate[] = "truncate";
static char __pyx_k__unreduce[] = "unreduce";
static char __pyx_k__DTYPE_INT[] = "DTYPE_INT";
static char __pyx_k__GatEngine[] = "GatEngine";
static char __pyx_k__HAS_SCIPY[] = "HAS_SCIPY";
static char __pyx_k__collapsed[] = "collapsed";
static char __pyx_k__empirical[] = "empirical";
static char __pyx_k__expansion[] = "expansion";
static char __pyx_k__extension[] = "extension";
static char __pyx_k__filenames[] = "filenames";
static char __pyx_k__getCenter[] = "getCenter";
static char __pyx_k__histogram[] = "histogram";
static char __pyx_k__increment[] = "increment";
static char __pyx_k__intersect[] = "intersect";
static char __pyx_k__isochores[] = "isochores";
static char __pyx_k__iteritems[] = "iteritems";
static char __pyx_k__loadIndex[] = "loadIndex";
static char __pyx_k__normalize[] = "normalize";
static char __pyx_k__reference[] = "reference";
static char __pyx_k__sample_id[] = "sample_id";
static char __pyx_k__temp_segs[] = "temp_segs";
static char __pyx_k__workspace[] = "workspace";
static char __pyx_k__IndexError[] = "IndexError";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k___toDensity[] = "_toDensity";
static char __pyx_k__aggregator[] = "aggregator";
static char __pyx_k__annotation[] = "annotation";
static char __pyx_k__getQValues[] = "getQValues";
static char __pyx_k__pi0_method[] = "pi0_method";
static char __pyx_k__startswith[] = "startswith";
static char __pyx_k__temp_annos[] = "temp_annos";
static char __pyx_k__track_size[] = "track_size";
static char __pyx_k__DTYPE_FLOAT[] = "DTYPE_FLOAT";
static char __pyx_k__ImportError[] = "ImportError";
static char __pyx_k__MemoryError[] = "MemoryError";
static char __pyx_k____getitem__[] = "__getitem__";
static char __pyx_k____setitem__[] = "__setitem__";
static char __pyx_k__annotations[] = "annotations";
static char __pyx_k__bucket_size[] = "bucket_size";
static char __pyx_k__collections[] = "collections";
static char __pyx_k__defaultdict[] = "defaultdict";
static char __pyx_k__format_fold[] = "format_fold";
static char __pyx_k__readFromBed[] = "readFromBed";
static char __pyx_k__segmentlist[] = "segmentlist";
static char __pyx_k__toIsochores[] = "toIsochores";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__bed_iterator[] = "bed_iterator";
static char __pyx_k__default_name[] = "default_name";
static char __pyx_k__isNormalized[] = "isNormalized";
static char __pyx_k__ntries_inner[] = "ntries_inner";
static char __pyx_k__ntries_outer[] = "ntries_outer";
static char __pyx_k__overlap_size[] = "overlap_size";
static char __pyx_k__pseudo_count[] = "pseudo_count";
static char __pyx_k__searchsorted[] = "searchsorted";
static char __pyx_k__segment_list[] = "segment_list";
static char __pyx_k__split_tracks[] = "split_tracks";
static char __pyx_k__tsv_iterator[] = "tsv_iterator";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k___defdictfloat[] = "_defdictfloat";
static char __pyx_k__adjustPValues[] = "adjustPValues";
static char __pyx_k__computeCounts[] = "computeCounts";
static char __pyx_k__format_counts[] = "format_counts";
static char __pyx_k__format_pvalue[] = "format_pvalue";
static char __pyx_k__fromIsochores[] = "fromIsochores";
static char __pyx_k__random_sample[] = "random_sample";
static char __pyx_k__segment_lists[] = "segment_lists";
static char __pyx_k__temp_segments[] = "temp_segments";
static char __pyx_k__track_density[] = "track_density";
static char __pyx_k__updatePValues[] = "updatePValues";
static char __pyx_k__updateQValues[] = "updateQValues";
static char __pyx_k__GatSegmentList[] = "GatSegmentList";
static char __pyx_k__allow_multiple[] = "allow_multiple";
static char __pyx_k__computeQValues[] = "computeQValues";
static char __pyx_k__format_density[] = "format_density";
static char __pyx_k__is_conditional[] = "is_conditional";
static char __pyx_k__temp_workspace[] = "temp_workspace";
static char __pyx_k__track_segments[] = "track_segments";
static char __pyx_k__annotation_size[] = "annotation_size";
static char __pyx_k__format_expected[] = "format_expected";
static char __pyx_k__getNormedPValue[] = "getNormedPValue";
static char __pyx_k__getSegmentLists[] = "getSegmentLists";
static char __pyx_k__overlap_density[] = "overlap_density";
static char __pyx_k__track_nsegments[] = "track_nsegments";
static char __pyx_k__current_position[] = "current_position";
static char __pyx_k__temp_annotations[] = "temp_annotations";
static char __pyx_k__annotator_results[] = "annotator_results";
static char __pyx_k__buildSamplerShift[] = "buildSamplerShift";
static char __pyx_k__current_workspace[] = "current_workspace";
static char __pyx_k__overlap_nsegments[] = "overlap_nsegments";
static char __pyx_k__annotation_density[] = "annotation_density";
static char __pyx_k__getEmpiricalPValue[] = "getEmpiricalPValue";
static char __pyx_k__annotation_segments[] = "annotation_segments";
static char __pyx_k__buildSamplerUniform[] = "buildSamplerUniform";
static char __pyx_k__current_orientation[] = "current_orientation";
static char __pyx_k__overlapWithSegments[] = "overlapWithSegments";
static char __pyx_k__workspace_generator[] = "workspace_generator";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_n_s_10;
static PyObject *__pyx_kp_s_100;
static PyObject *__pyx_kp_s_101;
static PyObject *__pyx_kp_s_102;
static PyObject *__pyx_kp_u_103;
static PyObject *__pyx_kp_u_105;
static PyObject *__pyx_kp_u_107;
static PyObject *__pyx_kp_u_109;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_u_110;
static PyObject *__pyx_kp_u_113;
static PyObject *__pyx_n_s_115;
static PyObject *__pyx_n_s_116;
static PyObject *__pyx_n_s_117;
static PyObject *__pyx_n_s_118;
static PyObject *__pyx_n_s_119;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_n_s_13;
static PyObject *__pyx_kp_s_130;
static PyObject *__pyx_kp_s_131;
static PyObject *__pyx_kp_s_132;
static PyObject *__pyx_kp_s_133;
static PyObject *__pyx_kp_s_134;
static PyObject *__pyx_kp_s_135;
static PyObject *__pyx_n_s_138;
static PyObject *__pyx_kp_s_139;
static PyObject *__pyx_kp_s_140;
static PyObject *__pyx_n_s_141;
static PyObject *__pyx_n_s_142;
static PyObject *__pyx_n_s_143;
static PyObject *__pyx_n_s_144;
static PyObject *__pyx_n_s_145;
static PyObject *__pyx_n_s_15;
static PyObject *__pyx_n_s_16;
static PyObject *__pyx_kp_s_160;
static PyObject *__pyx_n_s_161;
static PyObject *__pyx_kp_s_164;
static PyObject *__pyx_n_s_165;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_kp_s_171;
static PyObject *__pyx_n_s_172;
static PyObject *__pyx_kp_s_175;
static PyObject *__pyx_n_s_176;
static PyObject *__pyx_kp_s_179;
static PyObject *__pyx_n_s_180;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_196;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_n_s_20;
static PyObject *__pyx_kp_s_207;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_s_26;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_32;
static PyObject *__pyx_kp_s_35;
static PyObject *__pyx_kp_s_37;
static PyObject *__pyx_kp_s_38;
static PyObject *__pyx_kp_s_39;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_42;
static PyObject *__pyx_kp_s_43;
static PyObject *__pyx_kp_s_44;
static PyObject *__pyx_kp_s_45;
static PyObject *__pyx_kp_s_47;
static PyObject *__pyx_kp_s_49;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_50;
static PyObject *__pyx_kp_s_53;
static PyObject *__pyx_kp_s_54;
static PyObject *__pyx_kp_s_55;
static PyObject *__pyx_kp_s_56;
static PyObject *__pyx_kp_s_57;
static PyObject *__pyx_n_s_59;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_61;
static PyObject *__pyx_kp_s_62;
static PyObject *__pyx_kp_s_63;
static PyObject *__pyx_kp_s_65;
static PyObject *__pyx_kp_s_66;
static PyObject *__pyx_kp_s_67;
static PyObject *__pyx_kp_s_68;
static PyObject *__pyx_kp_s_69;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_n_s_70;
static PyObject *__pyx_kp_s_71;
static PyObject *__pyx_kp_s_72;
static PyObject *__pyx_kp_s_74;
static PyObject *__pyx_kp_s_75;
static PyObject *__pyx_n_s_78;
static PyObject *__pyx_kp_s_80;
static PyObject *__pyx_kp_s_81;
static PyObject *__pyx_kp_s_82;
static PyObject *__pyx_kp_s_83;
static PyObject *__pyx_kp_s_84;
static PyObject *__pyx_kp_s_85;
static PyObject *__pyx_kp_s_87;
static PyObject *__pyx_n_s_9;
static PyObject *__pyx_kp_s_90;
static PyObject *__pyx_kp_s_91;
static PyObject *__pyx_kp_s_92;
static PyObject *__pyx_kp_s_94;
static PyObject *__pyx_kp_s_95;
static PyObject *__pyx_kp_s_97;
static PyObject *__pyx_kp_s_98;
static PyObject *__pyx_kp_s_99;
static PyObject *__pyx_n_s__CI95high;
static PyObject *__pyx_n_s__CI95low;
static PyObject *__pyx_n_s__DTYPE_FLOAT;
static PyObject *__pyx_n_s__DTYPE_INT;
static PyObject *__pyx_n_s__E;
static PyObject *__pyx_n_s__GatEngine;
static PyObject *__pyx_n_s__GatSegmentList;
static PyObject *__pyx_n_s__HAS_SCIPY;
static PyObject *__pyx_n_s__IOError;
static PyObject *__pyx_n_s__IOTools;
static PyObject *__pyx_n_s__ImportError;
static PyObject *__pyx_n_s__IndexError;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__MemoryError;
static PyObject *__pyx_n_s__OSError;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__Stats;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__Track;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s___;
static PyObject *__pyx_n_s____call__;
static PyObject *__pyx_n_s____getitem__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____iter__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____setitem__;
static PyObject *__pyx_n_s____str__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___append;
static PyObject *__pyx_n_s___d;
static PyObject *__pyx_n_s___defdictfloat;
static PyObject *__pyx_n_s___genie;
static PyObject *__pyx_n_s___line;
static PyObject *__pyx_n_s___set;
static PyObject *__pyx_n_s___toDensity;
static PyObject *__pyx_n_s___toFold;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__absval;
static PyObject *__pyx_n_s__add;
static PyObject *__pyx_n_s__adjustPValues;
static PyObject *__pyx_n_s__aggregator;
static PyObject *__pyx_n_s__allocate;
static PyObject *__pyx_n_s__allow_multiple;
static PyObject *__pyx_n_s__annos;
static PyObject *__pyx_n_s__annotation;
static PyObject *__pyx_n_s__annotation_density;
static PyObject *__pyx_n_s__annotation_segments;
static PyObject *__pyx_n_s__annotation_size;
static PyObject *__pyx_n_s__annotations;
static PyObject *__pyx_n_s__annotator_results;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__ar;
static PyObject *__pyx_n_s__arange;
static PyObject *__pyx_n_s__args;
static PyObject *__pyx_n_s__argsort;
static PyObject *__pyx_n_s__array;
static PyObject *__pyx_n_s__b;
static PyObject *__pyx_n_s__basename;
static PyObject *__pyx_n_s__bed;
static PyObject *__pyx_n_s__bed_iterator;
static PyObject *__pyx_n_s__bucket_size;
static PyObject *__pyx_n_s__buildSamplerShift;
static PyObject *__pyx_n_s__buildSamplerUniform;
static PyObject *__pyx_n_s__cdf;
static PyObject *__pyx_n_s__clone;
static PyObject *__pyx_n_s__collapsed;
static PyObject *__pyx_n_s__collections;
static PyObject *__pyx_n_s__compile;
static PyObject *__pyx_n_s__computeCounts;
static PyObject *__pyx_n_s__computeQValues;
static PyObject *__pyx_n_s__contig;
static PyObject *__pyx_n_s__counter;
static PyObject *__pyx_n_s__counts;
static PyObject *__pyx_n_s__create;
static PyObject *__pyx_n_s__cumsum;
static PyObject *__pyx_n_s__current_orientation;
static PyObject *__pyx_n_s__current_position;
static PyObject *__pyx_n_s__current_workspace;
static PyObject *__pyx_n_s__debug;
static PyObject *__pyx_n_s__default_name;
static PyObject *__pyx_n_s__defaultdict;
static PyObject *__pyx_n_s__delete;
static PyObject *__pyx_n_s__dtype;
static PyObject *__pyx_n_s__empirical;
static PyObject *__pyx_n_s__end;
static PyObject *__pyx_n_s__exists;
static PyObject *__pyx_n_s__expand;
static PyObject *__pyx_n_s__expansion;
static PyObject *__pyx_n_s__expected;
static PyObject *__pyx_n_s__extend;
static PyObject *__pyx_n_s__extension;
static PyObject *__pyx_n_s__f;
static PyObject *__pyx_n_s__fdr;
static PyObject *__pyx_n_s__filename;
static PyObject *__pyx_n_s__filenames;
static PyObject *__pyx_n_s__filter;
static PyObject *__pyx_n_s__findall;
static PyObject *__pyx_n_s__float;
static PyObject *__pyx_n_s__fold;
static PyObject *__pyx_n_s__format_counts;
static PyObject *__pyx_n_s__format_density;
static PyObject *__pyx_n_s__format_expected;
static PyObject *__pyx_n_s__format_fold;
static PyObject *__pyx_n_s__format_pvalue;
static PyObject *__pyx_n_s__fromIsochores;
static PyObject *__pyx_n_s__gat;
static PyObject *__pyx_n_s__getCenter;
static PyObject *__pyx_n_s__getEmpiricalPValue;
static PyObject *__pyx_n_s__getNormedPValue;
static PyObject *__pyx_n_s__getQValues;
static PyObject *__pyx_n_s__getSegmentLists;
static PyObject *__pyx_n_s__getpid;
static PyObject *__pyx_n_s__groups;
static PyObject *__pyx_n_s__headers;
static PyObject *__pyx_n_s__histogram;
static PyObject *__pyx_n_s__increment;
static PyObject *__pyx_n_s__infile;
static PyObject *__pyx_n_s__int;
static PyObject *__pyx_n_s__intersect;
static PyObject *__pyx_n_s__isNormalized;
static PyObject *__pyx_n_s__is_conditional;
static PyObject *__pyx_n_s__isochore;
static PyObject *__pyx_n_s__isochores;
static PyObject *__pyx_n_s__items;
static PyObject *__pyx_n_s__iteritems;
static PyObject *__pyx_n_s__join;
static PyObject *__pyx_n_s__k;
static PyObject *__pyx_n_s__key;
static PyObject *__pyx_n_s__keys;
static PyObject *__pyx_n_s__kwargs;
static PyObject *__pyx_n_s__l;
static PyObject *__pyx_n_s__l2fold;
static PyObject *__pyx_n_s__line;
static PyObject *__pyx_n_s__lineno;
static PyObject *__pyx_n_s__load;
static PyObject *__pyx_n_s__loadIndex;
static PyObject *__pyx_n_s__log;
static PyObject *__pyx_n_s__math;
static PyObject *__pyx_n_s__mean;
static PyObject *__pyx_n_s__merge;
static PyObject *__pyx_n_s__merged;
static PyObject *__pyx_n_s__method;
static PyObject *__pyx_n_s__methodf;
static PyObject *__pyx_n_s__midpoint;
static PyObject *__pyx_n_s__min_pval;
static PyObject *__pyx_n_s__mode;
static PyObject *__pyx_n_s__msg;
static PyObject *__pyx_n_s__na;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__nbuckets;
static PyObject *__pyx_n_s__nbytes;
static PyObject *__pyx_n_s__next;
static PyObject *__pyx_n_s__norm;
static PyObject *__pyx_n_s__normalize;
static PyObject *__pyx_n_s__nsamples;
static PyObject *__pyx_n_s__ntries_inner;
static PyObject *__pyx_n_s__ntries_outer;
static PyObject *__pyx_n_s__numpy;
static PyObject *__pyx_n_s__object;
static PyObject *__pyx_n_s__observed;
static PyObject *__pyx_n_s__openFile;
static PyObject *__pyx_n_s__os;
static PyObject *__pyx_n_s__other;
static PyObject *__pyx_n_s__outfile;
static PyObject *__pyx_n_s__overlapWithSegments;
static PyObject *__pyx_n_s__overlap_density;
static PyObject *__pyx_n_s__overlap_nsegments;
static PyObject *__pyx_n_s__overlap_size;
static PyObject *__pyx_n_s__path;
static PyObject *__pyx_n_s__pi0_method;
static PyObject *__pyx_n_s__prefix;
static PyObject *__pyx_n_s__preparse;
static PyObject *__pyx_n_s__property;
static PyObject *__pyx_n_s__pseudo_count;
static PyObject *__pyx_n_s__pval;
static PyObject *__pyx_n_s__pvalue;
static PyObject *__pyx_n_s__pvalues;
static PyObject *__pyx_n_s__qvalue;
static PyObject *__pyx_n_s__qvalues;
static PyObject *__pyx_n_s__r;
static PyObject *__pyx_n_s__radius;
static PyObject *__pyx_n_s__randint;
static PyObject *__pyx_n_s__random;
static PyObject *__pyx_n_s__random_sample;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__re;
static PyObject *__pyx_n_s__readFromBed;
static PyObject *__pyx_n_s__readline;
static PyObject *__pyx_n_s__reference;
static PyObject *__pyx_n_s__regex;
static PyObject *__pyx_n_s__sample;
static PyObject *__pyx_n_s__sample_id;
static PyObject *__pyx_n_s__samples;
static PyObject *__pyx_n_s__scipy;
static PyObject *__pyx_n_s__search;
static PyObject *__pyx_n_s__searchsorted;
static PyObject *__pyx_n_s__segment_list;
static PyObject *__pyx_n_s__segment_lists;
static PyObject *__pyx_n_s__segmentlist;
static PyObject *__pyx_n_s__segments;
static PyObject *__pyx_n_s__segs;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__shuffle;
static PyObject *__pyx_n_s__smoother;
static PyObject *__pyx_n_s__sort;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__split_tracks;
static PyObject *__pyx_n_s__start;
static PyObject *__pyx_n_s__startswith;
static PyObject *__pyx_n_s__stats;
static PyObject *__pyx_n_s__std;
static PyObject *__pyx_n_s__stddev;
static PyObject *__pyx_n_s__storey;
static PyObject *__pyx_n_s__sum;
static PyObject *__pyx_n_s__temp_annos;
static PyObject *__pyx_n_s__temp_annotations;
static PyObject *__pyx_n_s__temp_segments;
static PyObject *__pyx_n_s__temp_segs;
static PyObject *__pyx_n_s__temp_workspace;
static PyObject *__pyx_n_s__toIsochores;
static PyObject *__pyx_n_s__toKey;
static PyObject *__pyx_n_s__total;
static PyObject *__pyx_n_s__track;
static PyObject *__pyx_n_s__track_density;
static PyObject *__pyx_n_s__track_nsegments;
static PyObject *__pyx_n_s__track_segments;
static PyObject *__pyx_n_s__track_size;
static PyObject *__pyx_n_s__tracks;
static PyObject *__pyx_n_s__truncate;
static PyObject *__pyx_n_s__tsv_iterator;
static PyObject *__pyx_n_s__types;
static PyObject *__pyx_n_s__unreduce;
static PyObject *__pyx_n_s__updatePValues;
static PyObject *__pyx_n_s__updateQValues;
static PyObject *__pyx_n_s__v;
static PyObject *__pyx_n_s__val;
static PyObject *__pyx_n_s__vals;
static PyObject *__pyx_n_s__value;
static PyObject *__pyx_n_s__values;
static PyObject *__pyx_n_s__vlambda;
static PyObject *__pyx_n_s__warn;
static PyObject *__pyx_n_s__workspace;
static PyObject *__pyx_n_s__workspace_generator;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__xrange;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_n_s__z;
static PyObject *__pyx_n_s__zeros;
static PyObject *__pyx_n_s__zip;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_15;
static PyObject *__pyx_int_100;
static PyObject *__pyx_int_100000;
static PyObject *__pyx_k_25;
static PyObject *__pyx_k_29;
static PyObject *__pyx_k_41;
static PyObject *__pyx_k_52;
static PyObject *__pyx_k_73;
static PyObject *__pyx_k_79;
static PyObject *__pyx_k_88;
static PyObject *__pyx_k_89;
static PyObject *__pyx_k_tuple_8;
static PyObject *__pyx_k_tuple_14;
static PyObject *__pyx_k_tuple_18;
static PyObject *__pyx_k_tuple_22;
static PyObject *__pyx_k_tuple_24;
static PyObject *__pyx_k_tuple_30;
static PyObject *__pyx_k_tuple_33;
static PyObject *__pyx_k_tuple_36;
static PyObject *__pyx_k_tuple_40;
static PyObject *__pyx_k_tuple_46;
static PyObject *__pyx_k_tuple_48;
static PyObject *__pyx_k_tuple_51;
static PyObject *__pyx_k_tuple_58;
static PyObject *__pyx_k_tuple_60;
static PyObject *__pyx_k_tuple_64;
static PyObject *__pyx_k_tuple_76;
static PyObject *__pyx_k_tuple_77;
static PyObject *__pyx_k_tuple_86;
static PyObject *__pyx_k_tuple_93;
static PyObject *__pyx_k_tuple_96;
static PyObject *__pyx_k_tuple_104;
static PyObject *__pyx_k_tuple_106;
static PyObject *__pyx_k_tuple_108;
static PyObject *__pyx_k_tuple_111;
static PyObject *__pyx_k_tuple_112;
static PyObject *__pyx_k_tuple_114;
static PyObject *__pyx_k_tuple_120;
static PyObject *__pyx_k_tuple_122;
static PyObject *__pyx_k_tuple_124;
static PyObject *__pyx_k_tuple_126;
static PyObject *__pyx_k_tuple_128;
static PyObject *__pyx_k_tuple_136;
static PyObject *__pyx_k_tuple_146;
static PyObject *__pyx_k_tuple_148;
static PyObject *__pyx_k_tuple_150;
static PyObject *__pyx_k_tuple_152;
static PyObject *__pyx_k_tuple_154;
static PyObject *__pyx_k_tuple_156;
static PyObject *__pyx_k_tuple_158;
static PyObject *__pyx_k_tuple_162;
static PyObject *__pyx_k_tuple_166;
static PyObject *__pyx_k_tuple_168;
static PyObject *__pyx_k_tuple_169;
static PyObject *__pyx_k_tuple_173;
static PyObject *__pyx_k_tuple_177;
static PyObject *__pyx_k_tuple_181;
static PyObject *__pyx_k_tuple_183;
static PyObject *__pyx_k_tuple_186;
static PyObject *__pyx_k_tuple_188;
static PyObject *__pyx_k_tuple_190;
static PyObject *__pyx_k_tuple_192;
static PyObject *__pyx_k_tuple_194;
static PyObject *__pyx_k_tuple_197;
static PyObject *__pyx_k_tuple_199;
static PyObject *__pyx_k_tuple_201;
static PyObject *__pyx_k_tuple_203;
static PyObject *__pyx_k_tuple_205;
static PyObject *__pyx_k_tuple_208;
static PyObject *__pyx_k_tuple_210;
static PyObject *__pyx_k_tuple_212;
static PyObject *__pyx_k_tuple_215;
static PyObject *__pyx_k_tuple_217;
static PyObject *__pyx_k_tuple_219;
static PyObject *__pyx_k_codeobj_31;
static PyObject *__pyx_k_codeobj_34;
static PyObject *__pyx_k_codeobj_121;
static PyObject *__pyx_k_codeobj_123;
static PyObject *__pyx_k_codeobj_125;
static PyObject *__pyx_k_codeobj_127;
static PyObject *__pyx_k_codeobj_129;
static PyObject *__pyx_k_codeobj_137;
static PyObject *__pyx_k_codeobj_147;
static PyObject *__pyx_k_codeobj_149;
static PyObject *__pyx_k_codeobj_151;
static PyObject *__pyx_k_codeobj_153;
static PyObject *__pyx_k_codeobj_155;
static PyObject *__pyx_k_codeobj_157;
static PyObject *__pyx_k_codeobj_159;
static PyObject *__pyx_k_codeobj_163;
static PyObject *__pyx_k_codeobj_167;
static PyObject *__pyx_k_codeobj_170;
static PyObject *__pyx_k_codeobj_174;
static PyObject *__pyx_k_codeobj_178;
static PyObject *__pyx_k_codeobj_182;
static PyObject *__pyx_k_codeobj_184;
static PyObject *__pyx_k_codeobj_185;
static PyObject *__pyx_k_codeobj_187;
static PyObject *__pyx_k_codeobj_189;
static PyObject *__pyx_k_codeobj_191;
static PyObject *__pyx_k_codeobj_193;
static PyObject *__pyx_k_codeobj_195;
static PyObject *__pyx_k_codeobj_198;
static PyObject *__pyx_k_codeobj_200;
static PyObject *__pyx_k_codeobj_202;
static PyObject *__pyx_k_codeobj_204;
static PyObject *__pyx_k_codeobj_206;
static PyObject *__pyx_k_codeobj_209;
static PyObject *__pyx_k_codeobj_211;
static PyObject *__pyx_k_codeobj_213;
static PyObject *__pyx_k_codeobj_214;
static PyObject *__pyx_k_codeobj_216;
static PyObject *__pyx_k_codeobj_218;
static PyObject *__pyx_k_codeobj_220;

/* "GatEngine.pyx":41
 * # declare as signed comparisons as a Position might be negative
 * @cython.profile(False)
 * cdef inline PositionDifference lmin( PositionDifference a, PositionDifference b):             # <<<<<<<<<<<<<<
 *     if a < b: return a
 *     return b
 */

static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_lmin(__pyx_t_14GatSegmentList_PositionDifference __pyx_v_a, __pyx_t_14GatSegmentList_PositionDifference __pyx_v_b) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("lmin", 0);

  /* "GatEngine.pyx":42
 * @cython.profile(False)
 * cdef inline PositionDifference lmin( PositionDifference a, PositionDifference b):
 *     if a < b: return a             # <<<<<<<<<<<<<<
 *     return b
 * 
 */
  __pyx_t_1 = (__pyx_v_a < __pyx_v_b);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":43
 * cdef inline PositionDifference lmin( PositionDifference a, PositionDifference b):
 *     if a < b: return a
 *     return b             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":46
 * 
 * @cython.profile(False)
 * cdef inline PositionDifference lmax( PositionDifference a, PositionDifference b):             # <<<<<<<<<<<<<<
 *     if a > b: return a
 *     return b
 */

static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_lmax(__pyx_t_14GatSegmentList_PositionDifference __pyx_v_a, __pyx_t_14GatSegmentList_PositionDifference __pyx_v_b) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("lmax", 0);

  /* "GatEngine.pyx":47
 * @cython.profile(False)
 * cdef inline PositionDifference lmax( PositionDifference a, PositionDifference b):
 *     if a > b: return a             # <<<<<<<<<<<<<<
 *     return b
 * 
 */
  __pyx_t_1 = (__pyx_v_a > __pyx_v_b);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":48
 * cdef inline PositionDifference lmax( PositionDifference a, PositionDifference b):
 *     if a > b: return a
 *     return b             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":51
 * 
 * @cython.profile(False)
 * cdef inline double dmin( double a, double b):             # <<<<<<<<<<<<<<
 *     if a < b: return a
 *     return b
 */

static CYTHON_INLINE double __pyx_f_9GatEngine_dmin(double __pyx_v_a, double __pyx_v_b) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("dmin", 0);

  /* "GatEngine.pyx":52
 * @cython.profile(False)
 * cdef inline double dmin( double a, double b):
 *     if a < b: return a             # <<<<<<<<<<<<<<
 *     return b
 * 
 */
  __pyx_t_1 = (__pyx_v_a < __pyx_v_b);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":53
 * cdef inline double dmin( double a, double b):
 *     if a < b: return a
 *     return b             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":56
 * 
 * @cython.profile(False)
 * cdef inline double dmax( double a, double b):             # <<<<<<<<<<<<<<
 *     if a > b: return a
 *     return b
 */

static CYTHON_INLINE double __pyx_f_9GatEngine_dmax(double __pyx_v_a, double __pyx_v_b) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("dmax", 0);

  /* "GatEngine.pyx":57
 * @cython.profile(False)
 * cdef inline double dmax( double a, double b):
 *     if a > b: return a             # <<<<<<<<<<<<<<
 *     return b
 * 
 */
  __pyx_t_1 = (__pyx_v_a > __pyx_v_b);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":58
 * cdef inline double dmax( double a, double b):
 *     if a > b: return a
 *     return b             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = __pyx_v_b;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":61
 * 
 * @cython.profile(False)
 * cdef inline PositionDifference segment_overlap( Segment a, Segment b ):             # <<<<<<<<<<<<<<
 *     return lmax(0, <PositionDifference>lmin( a.end, b.end) - <PositionDifference>lmax(a.start, b.start))
 * 
 */

static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_segment_overlap(struct __pyx_t_14GatSegmentList_Segment __pyx_v_a, struct __pyx_t_14GatSegmentList_Segment __pyx_v_b) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("segment_overlap", 0);

  /* "GatEngine.pyx":62
 * @cython.profile(False)
 * cdef inline PositionDifference segment_overlap( Segment a, Segment b ):
 *     return lmax(0, <PositionDifference>lmin( a.end, b.end) - <PositionDifference>lmax(a.start, b.start))             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = __pyx_f_9GatEngine_lmax(0, (((__pyx_t_14GatSegmentList_PositionDifference)__pyx_f_9GatEngine_lmin(__pyx_v_a.end, __pyx_v_b.end)) - ((__pyx_t_14GatSegmentList_PositionDifference)__pyx_f_9GatEngine_lmax(__pyx_v_a.start, __pyx_v_b.start))));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":65
 * 
 * @cython.profile(False)
 * cdef inline PositionDifference range_overlap( Position astart, Position aend, Position bstart, Position bend ):             # <<<<<<<<<<<<<<
 *     return lmax(0,
 *                 <PositionDifference>lmin( aend, bend) -
 */

static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_range_overlap(__pyx_t_14GatSegmentList_Position __pyx_v_astart, __pyx_t_14GatSegmentList_Position __pyx_v_aend, __pyx_t_14GatSegmentList_Position __pyx_v_bstart, __pyx_t_14GatSegmentList_Position __pyx_v_bend) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("range_overlap", 0);

  /* "GatEngine.pyx":68
 *     return lmax(0,
 *                 <PositionDifference>lmin( aend, bend) -
 *                 <PositionDifference>lmax(astart, bstart))             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = __pyx_f_9GatEngine_lmax(0, (((__pyx_t_14GatSegmentList_PositionDifference)__pyx_f_9GatEngine_lmin(__pyx_v_aend, __pyx_v_bend)) - ((__pyx_t_14GatSegmentList_PositionDifference)__pyx_f_9GatEngine_lmax(__pyx_v_astart, __pyx_v_bstart))));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":71
 * 
 * @cython.profile(False)
 * cdef inline PositionDifference segment_overlap_raw(  Segment a, Segment b ):             # <<<<<<<<<<<<<<
 *     return <PositionDifference>lmin(a.end, b.end) - <PositionDifference>lmax(a.start, b.start)
 * 
 */

static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_segment_overlap_raw(struct __pyx_t_14GatSegmentList_Segment __pyx_v_a, struct __pyx_t_14GatSegmentList_Segment __pyx_v_b) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("segment_overlap_raw", 0);

  /* "GatEngine.pyx":72
 * @cython.profile(False)
 * cdef inline PositionDifference segment_overlap_raw(  Segment a, Segment b ):
 *     return <PositionDifference>lmin(a.end, b.end) - <PositionDifference>lmax(a.start, b.start)             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = (((__pyx_t_14GatSegmentList_PositionDifference)__pyx_f_9GatEngine_lmin(__pyx_v_a.end, __pyx_v_b.end)) - ((__pyx_t_14GatSegmentList_PositionDifference)__pyx_f_9GatEngine_lmax(__pyx_v_a.start, __pyx_v_b.start)));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":75
 * 
 * @cython.profile(False)
 * cdef inline PositionDifference segment_length(  Segment a ):             # <<<<<<<<<<<<<<
 *     return <PositionDifference>a.end - <PositionDifference>a.start
 * 
 */

static CYTHON_INLINE __pyx_t_14GatSegmentList_PositionDifference __pyx_f_9GatEngine_segment_length(struct __pyx_t_14GatSegmentList_Segment __pyx_v_a) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("segment_length", 0);

  /* "GatEngine.pyx":76
 * @cython.profile(False)
 * cdef inline PositionDifference segment_length(  Segment a ):
 *     return <PositionDifference>a.end - <PositionDifference>a.start             # <<<<<<<<<<<<<<
 * 
 * # trick to permit const void * in function definitions
 */
  __pyx_r = (((__pyx_t_14GatSegmentList_PositionDifference)__pyx_v_a.end) - ((__pyx_t_14GatSegmentList_PositionDifference)__pyx_v_a.start));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":83
 * 
 * @cython.profile(False)
 * cdef int cmpSegments( const_void_ptr s1, const_void_ptr s2 ):             # <<<<<<<<<<<<<<
 *     return <PositionDifference>(<Segment *>s1).start - <PositionDifference>(<Segment *>s2).start
 * 
 */

static int __pyx_f_9GatEngine_cmpSegments(const void* __pyx_v_s1, const void* __pyx_v_s2) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cmpSegments", 0);

  /* "GatEngine.pyx":84
 * @cython.profile(False)
 * cdef int cmpSegments( const_void_ptr s1, const_void_ptr s2 ):
 *     return <PositionDifference>(<Segment *>s1).start - <PositionDifference>(<Segment *>s2).start             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = (((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_t_14GatSegmentList_Segment *)__pyx_v_s1)->start) - ((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_t_14GatSegmentList_Segment *)__pyx_v_s2)->start));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":87
 * 
 * @cython.profile(False)
 * cdef int cmpSegmentsStartAndEnd( const_void_ptr s1, const_void_ptr s2 ):             # <<<<<<<<<<<<<<
 *     cdef int x
 *     x = <PositionDifference>(<Segment *>s1).start - <PositionDifference>(<Segment *>s2).start
 */

static int __pyx_f_9GatEngine_cmpSegmentsStartAndEnd(const void* __pyx_v_s1, const void* __pyx_v_s2) {
  int __pyx_v_x;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("cmpSegmentsStartAndEnd", 0);

  /* "GatEngine.pyx":89
 * cdef int cmpSegmentsStartAndEnd( const_void_ptr s1, const_void_ptr s2 ):
 *     cdef int x
 *     x = <PositionDifference>(<Segment *>s1).start - <PositionDifference>(<Segment *>s2).start             # <<<<<<<<<<<<<<
 *     if x != 0: return x
 *     return <PositionDifference>(<Segment *>s1).end - <PositionDifference>(<Segment *>s2).end
 */
  __pyx_v_x = (((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_t_14GatSegmentList_Segment *)__pyx_v_s1)->start) - ((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_t_14GatSegmentList_Segment *)__pyx_v_s2)->start));

  /* "GatEngine.pyx":90
 *     cdef int x
 *     x = <PositionDifference>(<Segment *>s1).start - <PositionDifference>(<Segment *>s2).start
 *     if x != 0: return x             # <<<<<<<<<<<<<<
 *     return <PositionDifference>(<Segment *>s1).end - <PositionDifference>(<Segment *>s2).end
 * 
 */
  __pyx_t_1 = (__pyx_v_x != 0);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_x;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":91
 *     x = <PositionDifference>(<Segment *>s1).start - <PositionDifference>(<Segment *>s2).start
 *     if x != 0: return x
 *     return <PositionDifference>(<Segment *>s1).end - <PositionDifference>(<Segment *>s2).end             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = (((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_t_14GatSegmentList_Segment *)__pyx_v_s1)->end) - ((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_t_14GatSegmentList_Segment *)__pyx_v_s2)->end));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":94
 * 
 * @cython.profile(False)
 * cdef int cmpPosition( const_void_ptr s1, const_void_ptr s2 ):             # <<<<<<<<<<<<<<
 *     return (<Position*>s1)[0] - (<Position*>s2)[0]
 * 
 */

static int __pyx_f_9GatEngine_cmpPosition(const void* __pyx_v_s1, const void* __pyx_v_s2) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cmpPosition", 0);

  /* "GatEngine.pyx":95
 * @cython.profile(False)
 * cdef int cmpPosition( const_void_ptr s1, const_void_ptr s2 ):
 *     return (<Position*>s1)[0] - (<Position*>s2)[0]             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
  __pyx_r = ((((__pyx_t_14GatSegmentList_Position *)__pyx_v_s1)[0]) - (((__pyx_t_14GatSegmentList_Position *)__pyx_v_s2)[0]));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":98
 * 
 * @cython.profile(False)
 * cdef int cmpDouble( const_void_ptr s1, const_void_ptr s2 ):             # <<<<<<<<<<<<<<
 *     # see http://www.gnu.org/software/libc/manual/html_node/Comparison-Functions.html
 *     cdef double da = (<double*>s1)[0]
 */

static int __pyx_f_9GatEngine_cmpDouble(const void* __pyx_v_s1, const void* __pyx_v_s2) {
  double __pyx_v_da;
  double __pyx_v_db;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cmpDouble", 0);

  /* "GatEngine.pyx":100
 * cdef int cmpDouble( const_void_ptr s1, const_void_ptr s2 ):
 *     # see http://www.gnu.org/software/libc/manual/html_node/Comparison-Functions.html
 *     cdef double da = (<double*>s1)[0]             # <<<<<<<<<<<<<<
 *     cdef double db = (<double*>s2)[0]
 *     return (da > db) - (da < db)
 */
  __pyx_v_da = (((double *)__pyx_v_s1)[0]);

  /* "GatEngine.pyx":101
 *     # see http://www.gnu.org/software/libc/manual/html_node/Comparison-Functions.html
 *     cdef double da = (<double*>s1)[0]
 *     cdef double db = (<double*>s2)[0]             # <<<<<<<<<<<<<<
 *     return (da > db) - (da < db)
 * 
 */
  __pyx_v_db = (((double *)__pyx_v_s2)[0]);

  /* "GatEngine.pyx":102
 *     cdef double da = (<double*>s1)[0]
 *     cdef double db = (<double*>s2)[0]
 *     return (da > db) - (da < db)             # <<<<<<<<<<<<<<
 * 
 * cdef class SegmentListSamplerSlow:
 */
  __pyx_r = ((__pyx_v_da > __pyx_v_db) - (__pyx_v_da < __pyx_v_db));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_22SegmentListSamplerSlow_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_22SegmentListSamplerSlow_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segment_list,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segment_list)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerSlow.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segment_list), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segment_list", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_22SegmentListSamplerSlow___init__(((struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *)__pyx_v_self), __pyx_v_segment_list);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":110
 *     cdef Position total_size
 * 
 *     def __init__(self, SegmentList segment_list ):             # <<<<<<<<<<<<<<
 * 
 *         assert len(segment_list) > 0, "sampling from empty segment list"
 */

static int __pyx_pf_9GatEngine_22SegmentListSamplerSlow___init__(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list) {
  PyObject *__pyx_v_x = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":112
 *     def __init__(self, SegmentList segment_list ):
 * 
 *         assert len(segment_list) > 0, "sampling from empty segment list"             # <<<<<<<<<<<<<<
 * 
 *         self.segment_list = segment_list
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!(__pyx_t_1 > 0))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_1));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":114
 *         assert len(segment_list) > 0, "sampling from empty segment list"
 * 
 *         self.segment_list = segment_list             # <<<<<<<<<<<<<<
 *         self.cdf = numpy.cumsum( [x[1] - x[0] for x in self.segment_list ] )
 *         self.total_size = self.cdf[-1]
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_segment_list));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_segment_list));
  __Pyx_GOTREF(__pyx_v_self->segment_list);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->segment_list));
  __pyx_v_self->segment_list = __pyx_v_segment_list;

  /* "GatEngine.pyx":115
 * 
 *         self.segment_list = segment_list
 *         self.cdf = numpy.cumsum( [x[1] - x[0] for x in self.segment_list ] )             # <<<<<<<<<<<<<<
 *         self.total_size = self.cdf[-1]
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__cumsum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(((PyObject *)__pyx_v_self->segment_list)) || PyTuple_CheckExact(((PyObject *)__pyx_v_self->segment_list))) {
    __pyx_t_4 = ((PyObject *)__pyx_v_self->segment_list); __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_self->segment_list)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_4)) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_4)) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_6 = __pyx_t_5(__pyx_t_4);
      if (unlikely(!__pyx_t_6)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_6;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_x, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_x, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__Pyx_PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->cdf);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cdf));
  __pyx_v_self->cdf = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":116
 *         self.segment_list = segment_list
 *         self.cdf = numpy.cumsum( [x[1] - x[0] for x in self.segment_list ] )
 *         self.total_size = self.cdf[-1]             # <<<<<<<<<<<<<<
 * 
 *     cpdef sample( self, Position length ):
 */
  __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->cdf), -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_9 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->total_size = __pyx_t_9;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerSlow.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":118
 *         self.total_size = self.cdf[-1]
 * 
 *     cpdef sample( self, Position length ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.'''
 * 
 */

static PyObject *__pyx_pw_9GatEngine_22SegmentListSamplerSlow_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_length); /*proto*/
static PyObject *__pyx_f_9GatEngine_22SegmentListSamplerSlow_sample(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_length, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_r;
  __pyx_t_14GatSegmentList_Position __pyx_v_offset;
  __pyx_t_14GatSegmentList_Position __pyx_v_pos;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_overlap;
  size_t __pyx_v_segment_index;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_4;
  size_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_22SegmentListSamplerSlow_3sample)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":128
 *         cdef size_t segment_index
 * 
 *         r = numpy.random.randint( 0, self.total_size )             # <<<<<<<<<<<<<<
 *         segment_index = numpy.searchsorted( self.cdf, r )
 *         offset = r - self.cdf[segment_index]
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__randint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->total_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_r = __pyx_t_4;

  /* "GatEngine.pyx":129
 * 
 *         r = numpy.random.randint( 0, self.total_size )
 *         segment_index = numpy.searchsorted( self.cdf, r )             # <<<<<<<<<<<<<<
 *         offset = r - self.cdf[segment_index]
 *         if offset == 0:
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__searchsorted); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_r); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cdf));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->cdf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cdf));
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsSize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_segment_index = __pyx_t_5;

  /* "GatEngine.pyx":130
 *         r = numpy.random.randint( 0, self.total_size )
 *         segment_index = numpy.searchsorted( self.cdf, r )
 *         offset = r - self.cdf[segment_index]             # <<<<<<<<<<<<<<
 *         if offset == 0:
 *             pos = self.segment_list.segments[segment_index].start
 */
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_r); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->cdf), __pyx_v_segment_index, sizeof(size_t)+1, __Pyx_PyInt_FromSize_t); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Subtract(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_offset = __pyx_t_4;

  /* "GatEngine.pyx":131
 *         segment_index = numpy.searchsorted( self.cdf, r )
 *         offset = r - self.cdf[segment_index]
 *         if offset == 0:             # <<<<<<<<<<<<<<
 *             pos = self.segment_list.segments[segment_index].start
 *         else:
 */
  __pyx_t_6 = (__pyx_v_offset == 0);
  if (__pyx_t_6) {

    /* "GatEngine.pyx":132
 *         offset = r - self.cdf[segment_index]
 *         if offset == 0:
 *             pos = self.segment_list.segments[segment_index].start             # <<<<<<<<<<<<<<
 *         else:
 *             pos = self.segment_list.segments[segment_index].end + offset
 */
    __pyx_t_4 = (__pyx_v_self->segment_list->segments[__pyx_v_segment_index]).start;
    __pyx_v_pos = __pyx_t_4;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":134
 *             pos = self.segment_list.segments[segment_index].start
 *         else:
 *             pos = self.segment_list.segments[segment_index].end + offset             # <<<<<<<<<<<<<<
 * 
 *         overlap = self.segment_list.overlapWithRange( pos, pos+length )
 */
    __pyx_v_pos = ((__pyx_v_self->segment_list->segments[__pyx_v_segment_index]).end + __pyx_v_offset);
  }
  __pyx_L3:;

  /* "GatEngine.pyx":136
 *             pos = self.segment_list.segments[segment_index].end + offset
 * 
 *         overlap = self.segment_list.overlapWithRange( pos, pos+length )             # <<<<<<<<<<<<<<
 * 
 *         assert overlap > 0, "sample %i does not overlap with workspace: offset=%i, r=%i, index=%i/%i" %\
 */
  __pyx_v_overlap = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_self->segment_list->__pyx_vtab)->overlapWithRange(__pyx_v_self->segment_list, __pyx_v_pos, (__pyx_v_pos + __pyx_v_length), 0);

  /* "GatEngine.pyx":138
 *         overlap = self.segment_list.overlapWithRange( pos, pos+length )
 * 
 *         assert overlap > 0, "sample %i does not overlap with workspace: offset=%i, r=%i, index=%i/%i" %\             # <<<<<<<<<<<<<<
 *             (pos, r - self.cdf[segment_index], r, segment_index, self.segment_list.nsegments)
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_overlap > 0))) {

    /* "GatEngine.pyx":139
 * 
 *         assert overlap > 0, "sample %i does not overlap with workspace: offset=%i, r=%i, index=%i/%i" %\
 *             (pos, r - self.cdf[segment_index], r, segment_index, self.segment_list.nsegments)             # <<<<<<<<<<<<<<
 * 
 *         return pos, overlap
 */
    __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_r); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->cdf), __pyx_v_segment_index, sizeof(size_t)+1, __Pyx_PyInt_FromSize_t); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_r); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_segment_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyInt_FromSize_t(__pyx_v_self->segment_list->nsegments); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_3 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_8));
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":141
 *             (pos, r - self.cdf[segment_index], r, segment_index, self.segment_list.nsegments)
 * 
 *         return pos, overlap             # <<<<<<<<<<<<<<
 * 
 * cdef class SegmentListSamplerWithEdgeEffects:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyLong_FromUnsignedLong(__pyx_v_pos); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyInt_FromLong(__pyx_v_overlap); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerSlow.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_22SegmentListSamplerSlow_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_length); /*proto*/
static char __pyx_doc_9GatEngine_22SegmentListSamplerSlow_2sample[] = "SegmentListSamplerSlow.sample(self, Position length)\nreturn a new position within segment list.";
static PyObject *__pyx_pw_9GatEngine_22SegmentListSamplerSlow_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_length) {
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  assert(__pyx_arg_length); {
    __pyx_v_length = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_length); if (unlikely((__pyx_v_length == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerSlow.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_22SegmentListSamplerSlow_2sample(((struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *)__pyx_v_self), ((__pyx_t_14GatSegmentList_Position)__pyx_v_length));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":118
 *         self.total_size = self.cdf[-1]
 * 
 *     cpdef sample( self, Position length ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.'''
 * 
 */

static PyObject *__pyx_pf_9GatEngine_22SegmentListSamplerSlow_2sample(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_length) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerSlow *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_length, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerSlow.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segment_list,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segment_list)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerWithEdgeEffects.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segment_list), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segment_list", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects___init__(((struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)__pyx_v_self), __pyx_v_segment_list);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":150
 *     cdef Position nsegments
 * 
 *     def __init__(self, SegmentList segment_list ):             # <<<<<<<<<<<<<<
 *         cdef Position i, totsize
 *         assert len(segment_list) > 0, "sampling from empty segment list"
 */

static int __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects___init__(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list) {
  __pyx_t_14GatSegmentList_Position __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":152
 *     def __init__(self, SegmentList segment_list ):
 *         cdef Position i, totsize
 *         assert len(segment_list) > 0, "sampling from empty segment list"             # <<<<<<<<<<<<<<
 * 
 *         self.segment_list = segment_list
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!(__pyx_t_1 > 0))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_1));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":154
 *         assert len(segment_list) > 0, "sampling from empty segment list"
 * 
 *         self.segment_list = segment_list             # <<<<<<<<<<<<<<
 *         self.nsegments = len(segment_list)
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_segment_list));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_segment_list));
  __Pyx_GOTREF(__pyx_v_self->segment_list);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->segment_list));
  __pyx_v_self->segment_list = __pyx_v_segment_list;

  /* "GatEngine.pyx":155
 * 
 *         self.segment_list = segment_list
 *         self.nsegments = len(segment_list)             # <<<<<<<<<<<<<<
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nsegments = __pyx_t_1;

  /* "GatEngine.pyx":156
 *         self.segment_list = segment_list
 *         self.nsegments = len(segment_list)
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )             # <<<<<<<<<<<<<<
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 *         self.total_size = 0
 */
  __pyx_v_self->cdf = ((__pyx_t_14GatSegmentList_Position *)malloc(((sizeof(__pyx_t_14GatSegmentList_Position)) * __pyx_v_self->nsegments)));

  /* "GatEngine.pyx":157
 *         self.nsegments = len(segment_list)
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))             # <<<<<<<<<<<<<<
 *         self.total_size = 0
 *         for i from 0 <= i < len(segment_list):
 */
  __pyx_t_2 = (!(__pyx_v_self->cdf != 0));
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyInt_FromSize_t((sizeof(((sizeof(__pyx_t_14GatSegmentList_Position)) * __pyx_v_self->nsegments)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":158
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 *         self.total_size = 0             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < len(segment_list):
 *             self.total_size += segment_length( segment_list.segments[i] )
 */
  __pyx_v_self->total_size = 0;

  /* "GatEngine.pyx":159
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 *         self.total_size = 0
 *         for i from 0 <= i < len(segment_list):             # <<<<<<<<<<<<<<
 *             self.total_size += segment_length( segment_list.segments[i] )
 *             self.cdf[i] = self.total_size
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "GatEngine.pyx":160
 *         self.total_size = 0
 *         for i from 0 <= i < len(segment_list):
 *             self.total_size += segment_length( segment_list.segments[i] )             # <<<<<<<<<<<<<<
 *             self.cdf[i] = self.total_size
 * 
 */
    __pyx_v_self->total_size = (__pyx_v_self->total_size + __pyx_f_9GatEngine_segment_length((__pyx_v_segment_list->segments[__pyx_v_i])));

    /* "GatEngine.pyx":161
 *         for i from 0 <= i < len(segment_list):
 *             self.total_size += segment_length( segment_list.segments[i] )
 *             self.cdf[i] = self.total_size             # <<<<<<<<<<<<<<
 * 
 *     cpdef sample( self, Position length ):
 */
    __pyx_t_5 = __pyx_v_self->total_size;
    (__pyx_v_self->cdf[__pyx_v_i]) = __pyx_t_5;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerWithEdgeEffects.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":163
 *             self.cdf[i] = self.total_size
 * 
 *     cpdef sample( self, Position length ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.
 * 
 */

static PyObject *__pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_length); /*proto*/
static PyObject *__pyx_f_9GatEngine_33SegmentListSamplerWithEdgeEffects_sample(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_length, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_rpos;
  __pyx_t_14GatSegmentList_Position __pyx_v_rseg;
  __pyx_t_14GatSegmentList_Position __pyx_v_offset;
  __pyx_t_14GatSegmentList_Position __pyx_v_pos;
  __pyx_t_14GatSegmentList_Position __pyx_v_start;
  __pyx_t_14GatSegmentList_Position __pyx_v_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_overlap;
  size_t __pyx_v_segment_index;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_4;
  int __pyx_t_5;
  __pyx_t_14GatSegmentList_Position __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_3sample)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":178
 * 
 *         # r = rand() / (RAND_MAX / total_size + 1)
 *         rpos = numpy.random.randint( 0, self.total_size )             # <<<<<<<<<<<<<<
 *         segment_index = searchsorted( self.cdf,
 *                                       self.nsegments,
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__randint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->total_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rpos = __pyx_t_4;

  /* "GatEngine.pyx":183
 *                                       sizeof(Position),
 *                                       &rpos,
 *                                       &cmpPosition,             # <<<<<<<<<<<<<<
 *                                       )
 * 
 */
  __pyx_v_segment_index = searchsorted(__pyx_v_self->cdf, __pyx_v_self->nsegments, (sizeof(__pyx_t_14GatSegmentList_Position)), (&__pyx_v_rpos), (&__pyx_f_9GatEngine_cmpPosition));

  /* "GatEngine.pyx":186
 *                                       )
 * 
 *         offset = rpos - self.cdf[segment_index]             # <<<<<<<<<<<<<<
 *         if offset == 0:
 *             pos = self.segment_list.segments[segment_index+1].start
 */
  __pyx_v_offset = (__pyx_v_rpos - (__pyx_v_self->cdf[__pyx_v_segment_index]));

  /* "GatEngine.pyx":187
 * 
 *         offset = rpos - self.cdf[segment_index]
 *         if offset == 0:             # <<<<<<<<<<<<<<
 *             pos = self.segment_list.segments[segment_index+1].start
 *         else:
 */
  __pyx_t_5 = (__pyx_v_offset == 0);
  if (__pyx_t_5) {

    /* "GatEngine.pyx":188
 *         offset = rpos - self.cdf[segment_index]
 *         if offset == 0:
 *             pos = self.segment_list.segments[segment_index+1].start             # <<<<<<<<<<<<<<
 *         else:
 *             pos = self.segment_list.segments[segment_index].end + offset
 */
    __pyx_t_4 = (__pyx_v_self->segment_list->segments[(__pyx_v_segment_index + 1)]).start;
    __pyx_v_pos = __pyx_t_4;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":190
 *             pos = self.segment_list.segments[segment_index+1].start
 *         else:
 *             pos = self.segment_list.segments[segment_index].end + offset             # <<<<<<<<<<<<<<
 * 
 *         rseg = numpy.random.randint( 0, length )
 */
    __pyx_v_pos = ((__pyx_v_self->segment_list->segments[__pyx_v_segment_index]).end + __pyx_v_offset);
  }
  __pyx_L3:;

  /* "GatEngine.pyx":192
 *             pos = self.segment_list.segments[segment_index].end + offset
 * 
 *         rseg = numpy.random.randint( 0, length )             # <<<<<<<<<<<<<<
 * 
 *         start, end = pos - rseg, pos - rseg + length
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__randint); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_rseg = __pyx_t_4;

  /* "GatEngine.pyx":194
 *         rseg = numpy.random.randint( 0, length )
 * 
 *         start, end = pos - rseg, pos - rseg + length             # <<<<<<<<<<<<<<
 * 
 *         # print "sample %i-%i, offset=%i, pos=%i, rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 */
  __pyx_t_4 = (__pyx_v_pos - __pyx_v_rseg);
  __pyx_t_6 = ((__pyx_v_pos - __pyx_v_rseg) + __pyx_v_length);
  __pyx_v_start = __pyx_t_4;
  __pyx_v_end = __pyx_t_6;

  /* "GatEngine.pyx":200
 *         #      segment_index, self.segment_list.nsegments,
 *         #      self.segment_list.segments[segment_index] )
 *         overlap = 1             # <<<<<<<<<<<<<<
 * 
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: offset=%i, rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 */
  __pyx_v_overlap = 1;

  /* "GatEngine.pyx":202
 *         overlap = 1
 * 
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: offset=%i, rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\             # <<<<<<<<<<<<<<
 *             (start, end, offset, rpos, rseg,
 *              segment_index, self.segment_list.nsegments,
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_overlap > 0))) {

    /* "GatEngine.pyx":203
 * 
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: offset=%i, rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 *             (start, end, offset, rpos, rseg,             # <<<<<<<<<<<<<<
 *              segment_index, self.segment_list.nsegments,
 *              self.segment_list.segments[segment_index])
 */
    __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyLong_FromUnsignedLong(__pyx_v_rpos); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyLong_FromUnsignedLong(__pyx_v_rseg); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);

    /* "GatEngine.pyx":204
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: offset=%i, rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 *             (start, end, offset, rpos, rseg,
 *              segment_index, self.segment_list.nsegments,             # <<<<<<<<<<<<<<
 *              self.segment_list.segments[segment_index])
 * 
 */
    __pyx_t_9 = __Pyx_PyInt_FromSize_t(__pyx_v_segment_index); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyInt_FromSize_t(__pyx_v_self->segment_list->nsegments); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);

    /* "GatEngine.pyx":205
 *             (start, end, offset, rpos, rseg,
 *              segment_index, self.segment_list.nsegments,
 *              self.segment_list.segments[segment_index])             # <<<<<<<<<<<<<<
 * 
 *         return start, end, overlap
 */
    __pyx_t_11 = __pyx_convert__to_py___pyx_t_14GatSegmentList_Segment((__pyx_v_self->segment_list->segments[__pyx_v_segment_index])); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 7, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_11);
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_11));
    __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_11));
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":207
 *              self.segment_list.segments[segment_index])
 * 
 *         return start, end, overlap             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_10 = PyInt_FromLong(__pyx_v_overlap); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_10 = 0;
  __pyx_r = ((PyObject *)__pyx_t_9);
  __pyx_t_9 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerWithEdgeEffects.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_length); /*proto*/
static char __pyx_doc_9GatEngine_33SegmentListSamplerWithEdgeEffects_2sample[] = "SegmentListSamplerWithEdgeEffects.sample(self, Position length)\nreturn a new position within segment list.\n\n        This method both samples a position within the workspace\n        and a position within length.\n        ";
static PyObject *__pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_length) {
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  assert(__pyx_arg_length); {
    __pyx_v_length = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_length); if (unlikely((__pyx_v_length == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerWithEdgeEffects.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects_2sample(((struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)__pyx_v_self), ((__pyx_t_14GatSegmentList_Position)__pyx_v_length));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":163
 *             self.cdf[i] = self.total_size
 * 
 *     cpdef sample( self, Position length ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects_2sample(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_length) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerWithEdgeEffects *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_length, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SegmentListSamplerWithEdgeEffects.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects_4__dealloc__(((struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":209
 *         return start, end, overlap
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.cdf != NULL:
 *             free(self.cdf)
 */

static void __pyx_pf_9GatEngine_33SegmentListSamplerWithEdgeEffects_4__dealloc__(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":210
 * 
 *     def __dealloc__(self):
 *         if self.cdf != NULL:             # <<<<<<<<<<<<<<
 *             free(self.cdf)
 *             self.cdf = NULL
 */
  __pyx_t_1 = (__pyx_v_self->cdf != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":211
 *     def __dealloc__(self):
 *         if self.cdf != NULL:
 *             free(self.cdf)             # <<<<<<<<<<<<<<
 *             self.cdf = NULL
 * 
 */
    free(__pyx_v_self->cdf);

    /* "GatEngine.pyx":212
 *         if self.cdf != NULL:
 *             free(self.cdf)
 *             self.cdf = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef class SegmentListSampler:
 */
    __pyx_v_self->cdf = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18SegmentListSampler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_18SegmentListSampler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segment_list,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segment_list)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SegmentListSampler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segment_list), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segment_list", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_18SegmentListSampler___init__(((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_v_self), __pyx_v_segment_list);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":230
 *     cdef int nsegments
 * 
 *     def __init__(self, SegmentList segment_list ):             # <<<<<<<<<<<<<<
 *         cdef Position i, totsize
 *         assert len(segment_list) > 0, "sampling from empty segment list"
 */

static int __pyx_pf_9GatEngine_18SegmentListSampler___init__(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segment_list) {
  __pyx_t_14GatSegmentList_Position __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":232
 *     def __init__(self, SegmentList segment_list ):
 *         cdef Position i, totsize
 *         assert len(segment_list) > 0, "sampling from empty segment list"             # <<<<<<<<<<<<<<
 *         assert segment_list.isNormalized
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!(__pyx_t_1 > 0))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_1));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":233
 *         cdef Position i, totsize
 *         assert len(segment_list) > 0, "sampling from empty segment list"
 *         assert segment_list.isNormalized             # <<<<<<<<<<<<<<
 * 
 *         self.segment_list = segment_list
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_segment_list), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":235
 *         assert segment_list.isNormalized
 * 
 *         self.segment_list = segment_list             # <<<<<<<<<<<<<<
 *         self.nsegments = len(segment_list)
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_segment_list));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_segment_list));
  __Pyx_GOTREF(__pyx_v_self->segment_list);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->segment_list));
  __pyx_v_self->segment_list = __pyx_v_segment_list;

  /* "GatEngine.pyx":236
 * 
 *         self.segment_list = segment_list
 *         self.nsegments = len(segment_list)             # <<<<<<<<<<<<<<
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nsegments = __pyx_t_1;

  /* "GatEngine.pyx":237
 *         self.segment_list = segment_list
 *         self.nsegments = len(segment_list)
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )             # <<<<<<<<<<<<<<
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 *         self.total_size = 0
 */
  __pyx_v_self->cdf = ((__pyx_t_14GatSegmentList_Position *)malloc(((sizeof(__pyx_t_14GatSegmentList_Position)) * __pyx_v_self->nsegments)));

  /* "GatEngine.pyx":238
 *         self.nsegments = len(segment_list)
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))             # <<<<<<<<<<<<<<
 *         self.total_size = 0
 *         for i from 0 <= i < len(segment_list):
 */
  __pyx_t_3 = (!(__pyx_v_self->cdf != 0));
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(((sizeof(__pyx_t_14GatSegmentList_Position)) * __pyx_v_self->nsegments)))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":239
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nsegments )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 *         self.total_size = 0             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < len(segment_list):
 *             self.total_size += segment_length( segment_list.segments[i] )
 */
  __pyx_v_self->total_size = 0;

  /* "GatEngine.pyx":240
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nsegments ))
 *         self.total_size = 0
 *         for i from 0 <= i < len(segment_list):             # <<<<<<<<<<<<<<
 *             self.total_size += segment_length( segment_list.segments[i] )
 *             # -1, as searchsorted inserts on left
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_segment_list)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "GatEngine.pyx":241
 *         self.total_size = 0
 *         for i from 0 <= i < len(segment_list):
 *             self.total_size += segment_length( segment_list.segments[i] )             # <<<<<<<<<<<<<<
 *             # -1, as searchsorted inserts on left
 *             self.cdf[i] = self.total_size -1
 */
    __pyx_v_self->total_size = (__pyx_v_self->total_size + __pyx_f_9GatEngine_segment_length((__pyx_v_segment_list->segments[__pyx_v_i])));

    /* "GatEngine.pyx":243
 *             self.total_size += segment_length( segment_list.segments[i] )
 *             # -1, as searchsorted inserts on left
 *             self.cdf[i] = self.total_size -1             # <<<<<<<<<<<<<<
 * 
 *     cpdef sample( self, Position sample_length ):
 */
    (__pyx_v_self->cdf[__pyx_v_i]) = (__pyx_v_self->total_size - 1);
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.SegmentListSampler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":245
 *             self.cdf[i] = self.total_size -1
 * 
 *     cpdef sample( self, Position sample_length ):             # <<<<<<<<<<<<<<
 *         '''return a sampled segment of size sample_length.
 * 
 */

static PyObject *__pyx_pw_9GatEngine_18SegmentListSampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_sample_length); /*proto*/
static PyObject *__pyx_f_9GatEngine_18SegmentListSampler_sample(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_sample_length, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_start;
  __pyx_t_14GatSegmentList_Position __pyx_v_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_overlap;
  size_t __pyx_v_segment_index;
  struct __pyx_t_14GatSegmentList_Segment __pyx_v_chosen_segment;
  __pyx_t_14GatSegmentList_Position __pyx_v_random_pos_in_workspace;
  long __pyx_v_random_pos_in_segment;
  long __pyx_v_sampling_start;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  long __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_18SegmentListSampler_3sample)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_sample_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":265
 *         # sample a position
 *         # r = rand() / (RAND_MAX / total_size + 1)
 *         random_pos_in_workspace = numpy.random.randint( 0, self.total_size )             # <<<<<<<<<<<<<<
 *         segment_index = searchsorted( self.cdf,
 *                                       self.nsegments,
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__randint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->total_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_random_pos_in_workspace = __pyx_t_4;

  /* "GatEngine.pyx":270
 *                                       sizeof(Position),
 *                                       &random_pos_in_workspace,
 *                                       &cmpPosition,             # <<<<<<<<<<<<<<
 *                                       )
 * 
 */
  __pyx_v_segment_index = searchsorted(__pyx_v_self->cdf, __pyx_v_self->nsegments, (sizeof(__pyx_t_14GatSegmentList_Position)), (&__pyx_v_random_pos_in_workspace), (&__pyx_f_9GatEngine_cmpPosition));

  /* "GatEngine.pyx":273
 *                                       )
 * 
 *         assert 0 <= segment_index < self.nsegments, \             # <<<<<<<<<<<<<<
 *             "range error for %i: %i >= %i" % (random_pos_in_workspace, segment_index, self.nsegments)
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_5 = (0 <= __pyx_v_segment_index);
  if (__pyx_t_5) {
    __pyx_t_5 = (__pyx_v_segment_index < __pyx_v_self->nsegments);
  }
  if (unlikely(!__pyx_t_5)) {

    /* "GatEngine.pyx":274
 * 
 *         assert 0 <= segment_index < self.nsegments, \
 *             "range error for %i: %i >= %i" % (random_pos_in_workspace, segment_index, self.nsegments)             # <<<<<<<<<<<<<<
 * 
 *         chosen_segment = self.segment_list.segments[segment_index]
 */
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_random_pos_in_workspace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_segment_index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyInt_FromLong(__pyx_v_self->nsegments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":276
 *             "range error for %i: %i >= %i" % (random_pos_in_workspace, segment_index, self.nsegments)
 * 
 *         chosen_segment = self.segment_list.segments[segment_index]             # <<<<<<<<<<<<<<
 * 
 *         # resample start position within chosen segment
 */
  __pyx_v_chosen_segment = (__pyx_v_self->segment_list->segments[__pyx_v_segment_index]);

  /* "GatEngine.pyx":284
 *         # at the beginnig of a workspace
 *         # if chosen_segment.start is < than sample_length
 *         sampling_start = <long>chosen_segment.start - sample_length + 1             # <<<<<<<<<<<<<<
 * 
 *         # reduce sampling space if previous segment is closer than sample_length
 */
  __pyx_v_sampling_start = ((((long)__pyx_v_chosen_segment.start) - __pyx_v_sample_length) + 1);

  /* "GatEngine.pyx":289
 *         # to avoid edge effects at workspace boundaries where the distance between
 *         # the adjacent workspaces is less than sample_length
 *         if segment_index > 0:             # <<<<<<<<<<<<<<
 *             sampling_start = lmax( self.segment_list.segments[segment_index-1].end,
 *                                    sampling_start)
 */
  __pyx_t_5 = (__pyx_v_segment_index > 0);
  if (__pyx_t_5) {

    /* "GatEngine.pyx":291
 *         if segment_index > 0:
 *             sampling_start = lmax( self.segment_list.segments[segment_index-1].end,
 *                                    sampling_start)             # <<<<<<<<<<<<<<
 *         random_pos_in_segment = numpy.random.randint( \
 *             sampling_start,
 */
    __pyx_v_sampling_start = __pyx_f_9GatEngine_lmax((__pyx_v_self->segment_list->segments[(__pyx_v_segment_index - 1)]).end, __pyx_v_sampling_start);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":292
 *             sampling_start = lmax( self.segment_list.segments[segment_index-1].end,
 *                                    sampling_start)
 *         random_pos_in_segment = numpy.random.randint( \             # <<<<<<<<<<<<<<
 *             sampling_start,
 *             chosen_segment.end )
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__randint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":293
 *                                    sampling_start)
 *         random_pos_in_segment = numpy.random.randint( \
 *             sampling_start,             # <<<<<<<<<<<<<<
 *             chosen_segment.end )
 * 
 */
  __pyx_t_6 = PyInt_FromLong(__pyx_v_sampling_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "GatEngine.pyx":294
 *         random_pos_in_segment = numpy.random.randint( \
 *             sampling_start,
 *             chosen_segment.end )             # <<<<<<<<<<<<<<
 * 
 *         # adjust position by sampled amount
 */
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_chosen_segment.end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_6 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_7 = __Pyx_PyInt_AsLong(__pyx_t_3); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_random_pos_in_segment = __pyx_t_7;

  /* "GatEngine.pyx":299
 *         # adjust start position to negative coordinate
 *         # sampled length might be less sample_length
 *         start = lmax(0, random_pos_in_segment)             # <<<<<<<<<<<<<<
 *         end = random_pos_in_segment + sample_length
 * 
 */
  __pyx_v_start = __pyx_f_9GatEngine_lmax(0, __pyx_v_random_pos_in_segment);

  /* "GatEngine.pyx":300
 *         # sampled length might be less sample_length
 *         start = lmax(0, random_pos_in_segment)
 *         end = random_pos_in_segment + sample_length             # <<<<<<<<<<<<<<
 * 
 *         # print "sample %i-%i, rand_pos_workspace=%i, rand_pos_segment=%i, index=%i/%i, segment=%s" %\
 */
  __pyx_v_end = (__pyx_v_random_pos_in_segment + __pyx_v_sample_length);

  /* "GatEngine.pyx":306
 *         #      segment_index, self.segment_list.nsegments,
 *         #      self.segment_list.segments[segment_index] )
 *         overlap = range_overlap( chosen_segment.start, chosen_segment.end, start, end )             # <<<<<<<<<<<<<<
 * 
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 */
  __pyx_v_overlap = __pyx_f_9GatEngine_range_overlap(__pyx_v_chosen_segment.start, __pyx_v_chosen_segment.end, __pyx_v_start, __pyx_v_end);

  /* "GatEngine.pyx":308
 *         overlap = range_overlap( chosen_segment.start, chosen_segment.end, start, end )
 * 
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\             # <<<<<<<<<<<<<<
 *             (start, end, random_pos_in_workspace, random_pos_in_segment,
 *              segment_index,
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_overlap > 0))) {

    /* "GatEngine.pyx":309
 * 
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 *             (start, end, random_pos_in_workspace, random_pos_in_segment,             # <<<<<<<<<<<<<<
 *              segment_index,
 *              self.segment_list.nsegments,
 */
    __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_random_pos_in_workspace); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyInt_FromLong(__pyx_v_random_pos_in_segment); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "GatEngine.pyx":310
 *         assert overlap > 0, "sample %i-%i does not overlap with workspace: rpos=%i, rseg=%i, index=%i/%i, segment=%s" %\
 *             (start, end, random_pos_in_workspace, random_pos_in_segment,
 *              segment_index,             # <<<<<<<<<<<<<<
 *              self.segment_list.nsegments,
 *              self.segment_list.segments[segment_index])
 */
    __pyx_t_8 = __Pyx_PyInt_FromSize_t(__pyx_v_segment_index); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);

    /* "GatEngine.pyx":311
 *             (start, end, random_pos_in_workspace, random_pos_in_segment,
 *              segment_index,
 *              self.segment_list.nsegments,             # <<<<<<<<<<<<<<
 *              self.segment_list.segments[segment_index])
 * 
 */
    __pyx_t_9 = __Pyx_PyInt_FromSize_t(__pyx_v_self->segment_list->nsegments); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);

    /* "GatEngine.pyx":312
 *              segment_index,
 *              self.segment_list.nsegments,
 *              self.segment_list.segments[segment_index])             # <<<<<<<<<<<<<<
 * 
 *         return start, end, overlap
 */
    __pyx_t_10 = __pyx_convert__to_py___pyx_t_14GatSegmentList_Segment((__pyx_v_self->segment_list->segments[__pyx_v_segment_index])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = PyTuple_New(7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 6, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_10));
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_10));
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":314
 *              self.segment_list.segments[segment_index])
 * 
 *         return start, end, overlap             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = PyInt_FromLong(__pyx_v_overlap); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_9 = 0;
  __pyx_r = ((PyObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("GatEngine.SegmentListSampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18SegmentListSampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_sample_length); /*proto*/
static char __pyx_doc_9GatEngine_18SegmentListSampler_2sample[] = "SegmentListSampler.sample(self, Position sample_length)\nreturn a sampled segment of size sample_length.\n\n        \n        The length of the sampled segment might be less than *sample_length*\n        if it extends beyond a workspace boundary.\n        ";
static PyObject *__pyx_pw_9GatEngine_18SegmentListSampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_sample_length) {
  __pyx_t_14GatSegmentList_Position __pyx_v_sample_length;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  assert(__pyx_arg_sample_length); {
    __pyx_v_sample_length = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_sample_length); if (unlikely((__pyx_v_sample_length == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SegmentListSampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18SegmentListSampler_2sample(((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_v_self), ((__pyx_t_14GatSegmentList_Position)__pyx_v_sample_length));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":245
 *             self.cdf[i] = self.total_size -1
 * 
 *     cpdef sample( self, Position sample_length ):             # <<<<<<<<<<<<<<
 *         '''return a sampled segment of size sample_length.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18SegmentListSampler_2sample(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self, __pyx_t_14GatSegmentList_Position __pyx_v_sample_length) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_sample_length, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SegmentListSampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_18SegmentListSampler_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_18SegmentListSampler_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_18SegmentListSampler_4__dealloc__(((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":316
 *         return start, end, overlap
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.cdf != NULL:
 *             free(self.cdf)
 */

static void __pyx_pf_9GatEngine_18SegmentListSampler_4__dealloc__(struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":317
 * 
 *     def __dealloc__(self):
 *         if self.cdf != NULL:             # <<<<<<<<<<<<<<
 *             free(self.cdf)
 *             self.cdf = NULL
 */
  __pyx_t_1 = (__pyx_v_self->cdf != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":318
 *     def __dealloc__(self):
 *         if self.cdf != NULL:
 *             free(self.cdf)             # <<<<<<<<<<<<<<
 *             self.cdf = NULL
 * 
 */
    free(__pyx_v_self->cdf);

    /* "GatEngine.pyx":319
 *         if self.cdf != NULL:
 *             free(self.cdf)
 *             self.cdf = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef class HistogramSamplerSlow:
 */
    __pyx_v_self->cdf = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_20HistogramSamplerSlow_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_20HistogramSamplerSlow_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_histogram = 0;
  __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__histogram,&__pyx_n_s__bucket_size,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__histogram)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bucket_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_histogram = ((PyArrayObject *)values[0]);
    __pyx_v_bucket_size = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_bucket_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.HistogramSamplerSlow.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_histogram), __pyx_ptype_5numpy_ndarray, 1, "histogram", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_20HistogramSamplerSlow___init__(((struct __pyx_obj_9GatEngine_HistogramSamplerSlow *)__pyx_v_self), __pyx_v_histogram, __pyx_v_bucket_size);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":326
 *     cdef Position bucket_size
 * 
 *     def __init__(self,             # <<<<<<<<<<<<<<
 *                  numpy.ndarray histogram,
 *                  Position bucket_size ):
 */

static int __pyx_pf_9GatEngine_20HistogramSamplerSlow___init__(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *__pyx_v_self, PyArrayObject *__pyx_v_histogram, __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":330
 *                  Position bucket_size ):
 * 
 *         assert len(histogram) > 0, "sampling from empty histogram"             # <<<<<<<<<<<<<<
 * 
 *         self.cdf = numpy.cumsum( histogram, dtype = numpy.float )
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_histogram)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!(__pyx_t_1 > 0))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_7));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":332
 *         assert len(histogram) > 0, "sampling from empty histogram"
 * 
 *         self.cdf = numpy.cumsum( histogram, dtype = numpy.float )             # <<<<<<<<<<<<<<
 *         self.cdf /= self.cdf[-1]
 *         self.bucket_size = bucket_size
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__cumsum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_histogram));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_histogram));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_histogram));
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->cdf);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cdf));
  __pyx_v_self->cdf = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":333
 * 
 *         self.cdf = numpy.cumsum( histogram, dtype = numpy.float )
 *         self.cdf /= self.cdf[-1]             # <<<<<<<<<<<<<<
 *         self.bucket_size = bucket_size
 * 
 */
  __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->cdf), -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyNumber_InPlaceDivide(((PyObject *)__pyx_v_self->cdf), __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->cdf);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cdf));
  __pyx_v_self->cdf = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "GatEngine.pyx":334
 *         self.cdf = numpy.cumsum( histogram, dtype = numpy.float )
 *         self.cdf /= self.cdf[-1]
 *         self.bucket_size = bucket_size             # <<<<<<<<<<<<<<
 * 
 *     cpdef Position sample( self ):
 */
  __pyx_v_self->bucket_size = __pyx_v_bucket_size;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.HistogramSamplerSlow.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":336
 *         self.bucket_size = bucket_size
 * 
 *     cpdef Position sample( self ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.'''
 * 
 */

static PyObject *__pyx_pw_9GatEngine_20HistogramSamplerSlow_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static __pyx_t_14GatSegmentList_Position __pyx_f_9GatEngine_20HistogramSamplerSlow_sample(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *__pyx_v_self, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_base;
  __pyx_t_14GatSegmentList_Position __pyx_v_ip;
  double __pyx_v_r;
  __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size;
  __pyx_t_14GatSegmentList_Position __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_3;
  double __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_20HistogramSamplerSlow_3sample)) {
      __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 = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":342
 *         cdef double r
 *         cdef Position bucket_size
 *         bucket_size = self.bucket_size             # <<<<<<<<<<<<<<
 *         # note: could be made quicker by
 *         # - creating a sample random doubles once, see numpy.random_integers?
 */
  __pyx_t_3 = __pyx_v_self->bucket_size;
  __pyx_v_bucket_size = __pyx_t_3;

  /* "GatEngine.pyx":346
 *         # - creating a sample random doubles once, see numpy.random_integers?
 *         # - avoiding the binary search?
 *         r = numpy.random.random_sample( 1 )[0]             # <<<<<<<<<<<<<<
 *         ip = numpy.searchsorted( self.cdf, r )
 *         base = ip*bucket_size
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__random_sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_r = __pyx_t_4;

  /* "GatEngine.pyx":347
 *         # - avoiding the binary search?
 *         r = numpy.random.random_sample( 1 )[0]
 *         ip = numpy.searchsorted( self.cdf, r )             # <<<<<<<<<<<<<<
 *         base = ip*bucket_size
 *         if bucket_size>1 : return base + numpy.random.randint(0, bucket_size)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__searchsorted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cdf));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self->cdf));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cdf));
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_3 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ip = __pyx_t_3;

  /* "GatEngine.pyx":348
 *         r = numpy.random.random_sample( 1 )[0]
 *         ip = numpy.searchsorted( self.cdf, r )
 *         base = ip*bucket_size             # <<<<<<<<<<<<<<
 *         if bucket_size>1 : return base + numpy.random.randint(0, bucket_size)
 * 
 */
  __pyx_v_base = (__pyx_v_ip * __pyx_v_bucket_size);

  /* "GatEngine.pyx":349
 *         ip = numpy.searchsorted( self.cdf, r )
 *         base = ip*bucket_size
 *         if bucket_size>1 : return base + numpy.random.randint(0, bucket_size)             # <<<<<<<<<<<<<<
 * 
 *         return base
 */
  __pyx_t_6 = (__pyx_v_bucket_size > 1);
  if (__pyx_t_6) {
    __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__randint); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_bucket_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_7); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":351
 *         if bucket_size>1 : return base + numpy.random.randint(0, bucket_size)
 * 
 *         return base             # <<<<<<<<<<<<<<
 * 
 * cdef class HistogramSampler:
 */
  __pyx_r = __pyx_v_base;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("GatEngine.HistogramSamplerSlow.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_20HistogramSamplerSlow_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_20HistogramSamplerSlow_2sample[] = "HistogramSamplerSlow.sample(self) -> Position\nreturn a new position within segment list.";
static PyObject *__pyx_pw_9GatEngine_20HistogramSamplerSlow_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_20HistogramSamplerSlow_2sample(((struct __pyx_obj_9GatEngine_HistogramSamplerSlow *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":336
 *         self.bucket_size = bucket_size
 * 
 *     cpdef Position sample( self ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.'''
 * 
 */

static PyObject *__pyx_pf_9GatEngine_20HistogramSamplerSlow_2sample(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(((struct __pyx_vtabstruct_9GatEngine_HistogramSamplerSlow *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.HistogramSamplerSlow.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_16HistogramSampler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_16HistogramSampler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_histogram = 0;
  __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__histogram,&__pyx_n_s__bucket_size,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__histogram)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bucket_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_histogram = ((PyArrayObject *)values[0]);
    __pyx_v_bucket_size = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_bucket_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.HistogramSampler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_histogram), __pyx_ptype_5numpy_ndarray, 1, "histogram", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_16HistogramSampler___init__(((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_v_self), __pyx_v_histogram, __pyx_v_bucket_size);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":361
 * 
 *     @cython.boundscheck(False)
 *     def __init__(self,             # <<<<<<<<<<<<<<
 *                  numpy.ndarray[DTYPE_INT_t, ndim=1] histogram,
 *                  Position bucket_size ):
 */

static int __pyx_pf_9GatEngine_16HistogramSampler___init__(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self, PyArrayObject *__pyx_v_histogram, __pyx_t_14GatSegmentList_Position __pyx_v_bucket_size) {
  __pyx_t_14GatSegmentList_Position __pyx_v_i;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_histogram;
  __Pyx_Buffer __pyx_pybuffer_histogram;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_5;
  __pyx_t_14GatSegmentList_Position __pyx_t_6;
  __pyx_t_14GatSegmentList_Position __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __pyx_pybuffer_histogram.pybuffer.buf = NULL;
  __pyx_pybuffer_histogram.refcount = 0;
  __pyx_pybuffernd_histogram.data = NULL;
  __pyx_pybuffernd_histogram.rcbuffer = &__pyx_pybuffer_histogram;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_histogram.rcbuffer->pybuffer, (PyObject*)__pyx_v_histogram, &__Pyx_TypeInfo_nn___pyx_t_9GatEngine_DTYPE_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_histogram.diminfo[0].strides = __pyx_pybuffernd_histogram.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_histogram.diminfo[0].shape = __pyx_pybuffernd_histogram.rcbuffer->pybuffer.shape[0];

  /* "GatEngine.pyx":365
 *                  Position bucket_size ):
 *         cdef Position i
 *         self.cdf = NULL             # <<<<<<<<<<<<<<
 * 
 *         self.nbuckets = len(histogram)
 */
  __pyx_v_self->cdf = NULL;

  /* "GatEngine.pyx":367
 *         self.cdf = NULL
 * 
 *         self.nbuckets = len(histogram)             # <<<<<<<<<<<<<<
 *         assert self.nbuckets > 0, "sampling from empty histogram"
 * 
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_histogram)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nbuckets = __pyx_t_1;

  /* "GatEngine.pyx":368
 * 
 *         self.nbuckets = len(histogram)
 *         assert self.nbuckets > 0, "sampling from empty histogram"             # <<<<<<<<<<<<<<
 * 
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nbuckets )
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_self->nbuckets > 0))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_7));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":370
 *         assert self.nbuckets > 0, "sampling from empty histogram"
 * 
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nbuckets )             # <<<<<<<<<<<<<<
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nbuckets ))
 *         self.total_size = 0
 */
  __pyx_v_self->cdf = ((__pyx_t_14GatSegmentList_Position *)malloc(((sizeof(__pyx_t_14GatSegmentList_Position)) * __pyx_v_self->nbuckets)));

  /* "GatEngine.pyx":371
 * 
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nbuckets )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nbuckets ))             # <<<<<<<<<<<<<<
 *         self.total_size = 0
 *         for i from 0 <= i < self.nbuckets:
 */
  __pyx_t_2 = (!(__pyx_v_self->cdf != 0));
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyInt_FromSize_t((sizeof(((sizeof(__pyx_t_14GatSegmentList_Position)) * __pyx_v_self->nbuckets)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":372
 *         self.cdf = <Position*>malloc( sizeof(Position) * self.nbuckets )
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nbuckets ))
 *         self.total_size = 0             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < self.nbuckets:
 *             self.total_size += histogram[i]
 */
  __pyx_v_self->total_size = 0;

  /* "GatEngine.pyx":373
 *         if not self.cdf: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( sizeof(Position) * self.nbuckets ))
 *         self.total_size = 0
 *         for i from 0 <= i < self.nbuckets:             # <<<<<<<<<<<<<<
 *             self.total_size += histogram[i]
 *             self.cdf[i] = self.total_size
 */
  __pyx_t_5 = __pyx_v_self->nbuckets;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "GatEngine.pyx":374
 *         self.total_size = 0
 *         for i from 0 <= i < self.nbuckets:
 *             self.total_size += histogram[i]             # <<<<<<<<<<<<<<
 *             self.cdf[i] = self.total_size
 * 
 */
    __pyx_t_6 = __pyx_v_i;
    __pyx_v_self->total_size = (__pyx_v_self->total_size + (*__Pyx_BufPtrStrided1d(__pyx_t_9GatEngine_DTYPE_INT_t *, __pyx_pybuffernd_histogram.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_histogram.diminfo[0].strides)));

    /* "GatEngine.pyx":375
 *         for i from 0 <= i < self.nbuckets:
 *             self.total_size += histogram[i]
 *             self.cdf[i] = self.total_size             # <<<<<<<<<<<<<<
 * 
 *         self.bucket_size = bucket_size
 */
    __pyx_t_7 = __pyx_v_self->total_size;
    (__pyx_v_self->cdf[__pyx_v_i]) = __pyx_t_7;
  }

  /* "GatEngine.pyx":377
 *             self.cdf[i] = self.total_size
 * 
 *         self.bucket_size = bucket_size             # <<<<<<<<<<<<<<
 * 
 *     cpdef Position sample( self ):
 */
  __pyx_v_self->bucket_size = __pyx_v_bucket_size;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_histogram.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GatEngine.HistogramSampler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_histogram.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":379
 *         self.bucket_size = bucket_size
 * 
 *     cpdef Position sample( self ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.'''
 * 
 */

static PyObject *__pyx_pw_9GatEngine_16HistogramSampler_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static __pyx_t_14GatSegmentList_Position __pyx_f_9GatEngine_16HistogramSampler_sample(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_base;
  __pyx_t_14GatSegmentList_Position __pyx_v_index;
  __pyx_t_14GatSegmentList_Position __pyx_v_r;
  __pyx_t_14GatSegmentList_Position __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_16HistogramSampler_3sample)) {
      __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 = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":385
 * 
 *         # 1 to avoid 0 length
 *         if self.total_size > 1:             # <<<<<<<<<<<<<<
 *             r = numpy.random.randint( 1, self.total_size )
 *         else:
 */
  __pyx_t_4 = (__pyx_v_self->total_size > 1);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":386
 *         # 1 to avoid 0 length
 *         if self.total_size > 1:
 *             r = numpy.random.randint( 1, self.total_size )             # <<<<<<<<<<<<<<
 *         else:
 *             r = 1
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__randint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->total_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_r = __pyx_t_3;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":388
 *             r = numpy.random.randint( 1, self.total_size )
 *         else:
 *             r = 1             # <<<<<<<<<<<<<<
 * 
 *         index = searchsorted( self.cdf,
 */
    __pyx_v_r = 1;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":394
 *                               sizeof(Position),
 *                               &r,
 *                               &cmpPosition,             # <<<<<<<<<<<<<<
 *                               )
 *         base = index * self.bucket_size
 */
  __pyx_v_index = searchsorted(__pyx_v_self->cdf, __pyx_v_self->nbuckets, (sizeof(__pyx_t_14GatSegmentList_Position)), (&__pyx_v_r), (&__pyx_f_9GatEngine_cmpPosition));

  /* "GatEngine.pyx":396
 *                               &cmpPosition,
 *                               )
 *         base = index * self.bucket_size             # <<<<<<<<<<<<<<
 * 
 *         if self.bucket_size > 1 :
 */
  __pyx_v_base = (__pyx_v_index * __pyx_v_self->bucket_size);

  /* "GatEngine.pyx":398
 *         base = index * self.bucket_size
 * 
 *         if self.bucket_size > 1 :             # <<<<<<<<<<<<<<
 *             return base + numpy.random.randint(0, self.bucket_size)
 * 
 */
  __pyx_t_4 = (__pyx_v_self->bucket_size > 1);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":399
 * 
 *         if self.bucket_size > 1 :
 *             return base + numpy.random.randint(0, self.bucket_size)             # <<<<<<<<<<<<<<
 * 
 *         return base
 */
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__randint); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_6); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":401
 *             return base + numpy.random.randint(0, self.bucket_size)
 * 
 *         return base             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self ):
 */
  __pyx_r = __pyx_v_base;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("GatEngine.HistogramSampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_16HistogramSampler_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_16HistogramSampler_2sample[] = "HistogramSampler.sample(self) -> Position\nreturn a new position within segment list.";
static PyObject *__pyx_pw_9GatEngine_16HistogramSampler_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_16HistogramSampler_2sample(((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":379
 *         self.bucket_size = bucket_size
 * 
 *     cpdef Position sample( self ):             # <<<<<<<<<<<<<<
 *         '''return a new position within segment list.'''
 * 
 */

static PyObject *__pyx_pf_9GatEngine_16HistogramSampler_2sample(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(((struct __pyx_vtabstruct_9GatEngine_HistogramSampler *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.HistogramSampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_16HistogramSampler_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_16HistogramSampler_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_16HistogramSampler_4__dealloc__(((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":403
 *         return base
 * 
 *     def __dealloc__(self ):             # <<<<<<<<<<<<<<
 *         if self.cdf != NULL:
 *             free( self.cdf )
 */

static void __pyx_pf_9GatEngine_16HistogramSampler_4__dealloc__(struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":404
 * 
 *     def __dealloc__(self ):
 *         if self.cdf != NULL:             # <<<<<<<<<<<<<<
 *             free( self.cdf )
 *             self.cdf = NULL
 */
  __pyx_t_1 = (__pyx_v_self->cdf != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":405
 *     def __dealloc__(self ):
 *         if self.cdf != NULL:
 *             free( self.cdf )             # <<<<<<<<<<<<<<
 *             self.cdf = NULL
 * 
 */
    free(__pyx_v_self->cdf);

    /* "GatEngine.pyx":406
 *         if self.cdf != NULL:
 *             free( self.cdf )
 *             self.cdf = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef class Sampler:
 */
    __pyx_v_self->cdf = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_16SamplerAnnotator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_16SamplerAnnotator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bucket_size = 0;
  PyObject *__pyx_v_nbuckets = 0;
  PyObject *__pyx_v_nunsuccessful_rounds = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bucket_size,&__pyx_n_s__nbuckets,&__pyx_n_s_9,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)__pyx_int_1);
    values[1] = ((PyObject *)__pyx_int_100000);
    values[2] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bucket_size);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbuckets);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_9);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bucket_size = values[0];
    __pyx_v_nbuckets = values[1];
    __pyx_v_nunsuccessful_rounds = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerAnnotator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_16SamplerAnnotator___init__(((struct __pyx_obj_9GatEngine_SamplerAnnotator *)__pyx_v_self), __pyx_v_bucket_size, __pyx_v_nbuckets, __pyx_v_nunsuccessful_rounds);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":468
 *     cdef int nunsuccessful_rounds
 * 
 *     def __init__( self, bucket_size = 1, nbuckets = 100000, nunsuccessful_rounds = 0 ):             # <<<<<<<<<<<<<<
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets
 */

static int __pyx_pf_9GatEngine_16SamplerAnnotator___init__(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets, PyObject *__pyx_v_nunsuccessful_rounds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":469
 * 
 *     def __init__( self, bucket_size = 1, nbuckets = 100000, nunsuccessful_rounds = 0 ):
 *         self.bucket_size = bucket_size             # <<<<<<<<<<<<<<
 *         self.nbuckets = nbuckets
 *         self.nunsuccessful_rounds = nunsuccessful_rounds
 */
  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_bucket_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->bucket_size = __pyx_t_1;

  /* "GatEngine.pyx":470
 *     def __init__( self, bucket_size = 1, nbuckets = 100000, nunsuccessful_rounds = 0 ):
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets             # <<<<<<<<<<<<<<
 *         self.nunsuccessful_rounds = nunsuccessful_rounds
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_nbuckets); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nbuckets = __pyx_t_2;

  /* "GatEngine.pyx":471
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets
 *         self.nunsuccessful_rounds = nunsuccessful_rounds             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_nunsuccessful_rounds); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nunsuccessful_rounds = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.SamplerAnnotator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_16SamplerAnnotator_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_16SamplerAnnotator_2__reduce__[] = "SamplerAnnotator.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_16SamplerAnnotator_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_16SamplerAnnotator_2__reduce__(((struct __pyx_obj_9GatEngine_SamplerAnnotator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":473
 *         self.nunsuccessful_rounds = nunsuccessful_rounds
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildSamplerAnnotator, (self.bucket_size,
 *                                         self.nbuckets,
 */

static PyObject *__pyx_pf_9GatEngine_16SamplerAnnotator_2__reduce__(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":474
 * 
 *     def __reduce__(self):
 *         return (buildSamplerAnnotator, (self.bucket_size,             # <<<<<<<<<<<<<<
 *                                         self.nbuckets,
 *                                         self.nunsuccessful_rounds ) )
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "GatEngine.pyx":475
 *     def __reduce__(self):
 *         return (buildSamplerAnnotator, (self.bucket_size,
 *                                         self.nbuckets,             # <<<<<<<<<<<<<<
 *                                         self.nunsuccessful_rounds ) )
 * 
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "GatEngine.pyx":476
 *         return (buildSamplerAnnotator, (self.bucket_size,
 *                                         self.nbuckets,
 *                                         self.nunsuccessful_rounds ) )             # <<<<<<<<<<<<<<
 * 
 *     cpdef SegmentList sample( self,
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_self->nunsuccessful_rounds); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.SamplerAnnotator.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":478
 *                                         self.nunsuccessful_rounds ) )
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                               SegmentList segments,
 *                               SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_16SamplerAnnotator_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_16SamplerAnnotator_sample(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_remaining;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_true_remaining;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_overlap;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_ltotal;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_length;
  int __pyx_v_nunsuccessful_rounds;
  int __pyx_v_max_unsuccessful_rounds;
  __pyx_t_14GatSegmentList_Position __pyx_v_start;
  __pyx_t_14GatSegmentList_Position __pyx_v_end;
  struct __pyx_t_14GatSegmentList_Segment __pyx_v_sampled_segment;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sampled_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_unintersected_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_intersected_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_tmp_segments = 0;
  struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_sls = 0;
  struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_temp_sampler = 0;
  PyObject *__pyx_v_histogram = NULL;
  PyObject *__pyx_v_bucket_size = NULL;
  struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_hs = NULL;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_11;
  __pyx_t_14GatSegmentList_Position __pyx_t_12;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_t_13;
  int __pyx_t_14;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_16SamplerAnnotator_5sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":498
 *         cdef SegmentListSampler sls, temp_sampler
 * 
 *         assert segments.isNormalized, "segment list is not normalized"             # <<<<<<<<<<<<<<
 *         assert workspace.isNormalized, "workspace is not normalized"
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_segments), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_11));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":499
 * 
 *         assert segments.isNormalized, "segment list is not normalized"
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         unintersected_segments = SegmentList()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":501
 *         assert workspace.isNormalized, "workspace is not normalized"
 * 
 *         unintersected_segments = SegmentList()             # <<<<<<<<<<<<<<
 *         intersected_segments = SegmentList()
 * 
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_unintersected_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":502
 * 
 *         unintersected_segments = SegmentList()
 *         intersected_segments = SegmentList()             # <<<<<<<<<<<<<<
 * 
 *         # collect all segments in workspace
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_intersected_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":506
 *         # collect all segments in workspace
 *         # This method does not truncate.
 *         working_segments = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         working_segments.filter( workspace )
 *         if len(working_segments) == 0:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":507
 *         # This method does not truncate.
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )             # <<<<<<<<<<<<<<
 *         if len(working_segments) == 0:
 *             return intersected_segments
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->filter(__pyx_v_working_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":508
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )
 *         if len(working_segments) == 0:             # <<<<<<<<<<<<<<
 *             return intersected_segments
 * 
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_5 == 0);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":509
 *         working_segments.filter( workspace )
 *         if len(working_segments) == 0:
 *             return intersected_segments             # <<<<<<<<<<<<<<
 * 
 *         # get nucleotides that need to be sampled
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_intersected_segments));
    __pyx_r = __pyx_v_intersected_segments;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":513
 *         # get nucleotides that need to be sampled
 *         # only count overlap within workspace
 *         tmp_segments = SegmentList( clone = working_segments )             # <<<<<<<<<<<<<<
 *         tmp_segments.intersect( workspace )
 *         ltotal = tmp_segments.sum()
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_working_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_tmp_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":514
 *         # only count overlap within workspace
 *         tmp_segments = SegmentList( clone = working_segments )
 *         tmp_segments.intersect( workspace )             # <<<<<<<<<<<<<<
 *         ltotal = tmp_segments.sum()
 * 
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_tmp_segments->__pyx_vtab)->intersect(__pyx_v_tmp_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":515
 *         tmp_segments = SegmentList( clone = working_segments )
 *         tmp_segments.intersect( workspace )
 *         ltotal = tmp_segments.sum()             # <<<<<<<<<<<<<<
 * 
 *         # create space for sampled segments, add additional 10%
 */
  __pyx_v_ltotal = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_tmp_segments->__pyx_vtab)->sum(__pyx_v_tmp_segments, 0);

  /* "GatEngine.pyx":519
 *         # create space for sampled segments, add additional 10%
 *         # safety margin to avoid realloc calls
 *         sampled_segments = SegmentList( allocate = int(1.1 * len(segments)) )             # <<<<<<<<<<<<<<
 * 
 *         # build a segment length histogram
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyFloat_FromDouble((1.1 * __pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__allocate), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sampled_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":522
 * 
 *         # build a segment length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                                          self.nbuckets )
 * 
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_working_segments), __pyx_n_s_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "GatEngine.pyx":523
 *         # build a segment length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,
 *                                                                          self.nbuckets )             # <<<<<<<<<<<<<<
 * 
 *         hs = HistogramSampler( histogram, bucket_size )
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L5_unpacking_done:;
  }

  /* "GatEngine.pyx":522
 * 
 *         # build a segment length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                                          self.nbuckets )
 * 
 */
  __pyx_v_histogram = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_bucket_size = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":525
 *                                                                          self.nbuckets )
 * 
 *         hs = HistogramSampler( histogram, bucket_size )             # <<<<<<<<<<<<<<
 * 
 *         # set up segment sampler
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_histogram);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_histogram);
  __Pyx_GIVEREF(__pyx_v_histogram);
  __Pyx_INCREF(__pyx_v_bucket_size);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_bucket_size);
  __Pyx_GIVEREF(__pyx_v_bucket_size);
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_HistogramSampler)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_hs = ((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":528
 * 
 *         # set up segment sampler
 *         sls = SegmentListSampler( workspace )             # <<<<<<<<<<<<<<
 * 
 *         remaining = ltotal
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SegmentListSampler)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_sls = ((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":530
 *         sls = SegmentListSampler( workspace )
 * 
 *         remaining = ltotal             # <<<<<<<<<<<<<<
 *         true_remaining = remaining
 *         nunsuccessful_rounds = 0
 */
  __pyx_v_remaining = __pyx_v_ltotal;

  /* "GatEngine.pyx":531
 * 
 *         remaining = ltotal
 *         true_remaining = remaining             # <<<<<<<<<<<<<<
 *         nunsuccessful_rounds = 0
 *         max_unsuccessful_rounds = 20
 */
  __pyx_v_true_remaining = __pyx_v_remaining;

  /* "GatEngine.pyx":532
 *         remaining = ltotal
 *         true_remaining = remaining
 *         nunsuccessful_rounds = 0             # <<<<<<<<<<<<<<
 *         max_unsuccessful_rounds = 20
 * 
 */
  __pyx_v_nunsuccessful_rounds = 0;

  /* "GatEngine.pyx":533
 *         true_remaining = remaining
 *         nunsuccessful_rounds = 0
 *         max_unsuccessful_rounds = 20             # <<<<<<<<<<<<<<
 * 
 *         while true_remaining > 0 and nunsuccessful_rounds < max_unsuccessful_rounds:
 */
  __pyx_v_max_unsuccessful_rounds = 20;

  /* "GatEngine.pyx":535
 *         max_unsuccessful_rounds = 20
 * 
 *         while true_remaining > 0 and nunsuccessful_rounds < max_unsuccessful_rounds:             # <<<<<<<<<<<<<<
 * 
 *             ###################################################################
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_true_remaining > 0);
    if (__pyx_t_4) {
      __pyx_t_8 = (__pyx_v_nunsuccessful_rounds < __pyx_v_max_unsuccessful_rounds);
      __pyx_t_9 = __pyx_t_8;
    } else {
      __pyx_t_9 = __pyx_t_4;
    }
    if (!__pyx_t_9) break;

    /* "GatEngine.pyx":539
 *             ###################################################################
 *             # Sample a segment length from the histogram
 *             length = hs.sample()             # <<<<<<<<<<<<<<
 *             assert length > 0
 * 
 */
    __pyx_v_length = ((struct __pyx_vtabstruct_9GatEngine_HistogramSampler *)__pyx_v_hs->__pyx_vtab)->sample(__pyx_v_hs, 0);

    /* "GatEngine.pyx":540
 *             # Sample a segment length from the histogram
 *             length = hs.sample()
 *             assert length > 0             # <<<<<<<<<<<<<<
 * 
 *             ###################################################################
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_length > 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "GatEngine.pyx":545
 *             # If we can now potentially get required number of nucleotides, recompute
 *             # the required amount since we might need more due to overlap
 *             if remaining <= length:             # <<<<<<<<<<<<<<
 *                 # add current sampled segments to list of segments
 *                 unintersected_segments.extend( sampled_segments )
 */
    __pyx_t_9 = (__pyx_v_remaining <= __pyx_v_length);
    if (__pyx_t_9) {

      /* "GatEngine.pyx":547
 *             if remaining <= length:
 *                 # add current sampled segments to list of segments
 *                 unintersected_segments.extend( sampled_segments )             # <<<<<<<<<<<<<<
 *                 # merge overlapping and adjacent segments
 *                 unintersected_segments.merge( 0 )
 */
      __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_unintersected_segments->__pyx_vtab)->extend(__pyx_v_unintersected_segments, __pyx_v_sampled_segments, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":549
 *                 unintersected_segments.extend( sampled_segments )
 *                 # merge overlapping and adjacent segments
 *                 unintersected_segments.merge( 0 )             # <<<<<<<<<<<<<<
 * 
 *                 # reset sampled segments
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_unintersected_segments->__pyx_vtab)->merge(__pyx_v_unintersected_segments, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":552
 * 
 *                 # reset sampled segments
 *                 sampled_segments.clear()             # <<<<<<<<<<<<<<
 * 
 *                 ############################################
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sampled_segments->__pyx_vtab)->clear(__pyx_v_sampled_segments, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":556
 *                 ############################################
 *                 # compute overlap with workspace
 *                 intersected_segments = SegmentList( clone = unintersected_segments )             # <<<<<<<<<<<<<<
 *                 intersected_segments.intersect( workspace )
 * 
 */
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_unintersected_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_intersected_segments));
      __pyx_v_intersected_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":557
 *                 # compute overlap with workspace
 *                 intersected_segments = SegmentList( clone = unintersected_segments )
 *                 intersected_segments.intersect( workspace )             # <<<<<<<<<<<<<<
 * 
 *                 assert intersected_segments.sum() <= unintersected_segments.sum()
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_intersected_segments->__pyx_vtab)->intersect(__pyx_v_intersected_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "GatEngine.pyx":559
 *                 intersected_segments.intersect( workspace )
 * 
 *                 assert intersected_segments.sum() <= unintersected_segments.sum()             # <<<<<<<<<<<<<<
 * 
 *                 # recompute bases remaining to be covered
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_intersected_segments->__pyx_vtab)->sum(__pyx_v_intersected_segments, 0) <= ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_unintersected_segments->__pyx_vtab)->sum(__pyx_v_unintersected_segments, 0)))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "GatEngine.pyx":562
 * 
 *                 # recompute bases remaining to be covered
 *                 remaining = ltotal - <PositionDifference>intersected_segments.sum()             # <<<<<<<<<<<<<<
 * 
 *                 # check if we managed to increase coverage
 */
      __pyx_v_remaining = (__pyx_v_ltotal - ((__pyx_t_14GatSegmentList_PositionDifference)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_intersected_segments->__pyx_vtab)->sum(__pyx_v_intersected_segments, 0)));

      /* "GatEngine.pyx":565
 * 
 *                 # check if we managed to increase coverage
 *                 if true_remaining == remaining:             # <<<<<<<<<<<<<<
 *                     nunsuccessful_rounds += 1
 *                 else:
 */
      __pyx_t_9 = (__pyx_v_true_remaining == __pyx_v_remaining);
      if (__pyx_t_9) {

        /* "GatEngine.pyx":566
 *                 # check if we managed to increase coverage
 *                 if true_remaining == remaining:
 *                     nunsuccessful_rounds += 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     true_remaining = remaining
 */
        __pyx_v_nunsuccessful_rounds = (__pyx_v_nunsuccessful_rounds + 1);
        goto __pyx_L9;
      }
      /*else*/ {

        /* "GatEngine.pyx":568
 *                     nunsuccessful_rounds += 1
 *                 else:
 *                     true_remaining = remaining             # <<<<<<<<<<<<<<
 * 
 *             # deal with overshoot
 */
        __pyx_v_true_remaining = __pyx_v_remaining;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "GatEngine.pyx":571
 * 
 *             # deal with overshoot
 *             if true_remaining < 0:             # <<<<<<<<<<<<<<
 *                 temp_sampler = SegmentListSampler( unintersected_segments )
 * 
 */
    __pyx_t_9 = (__pyx_v_true_remaining < 0);
    if (__pyx_t_9) {

      /* "GatEngine.pyx":572
 *             # deal with overshoot
 *             if true_remaining < 0:
 *                 temp_sampler = SegmentListSampler( unintersected_segments )             # <<<<<<<<<<<<<<
 * 
 *                 # sample a position from current list of sampled segments
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_unintersected_segments));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_unintersected_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_unintersected_segments));
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SegmentListSampler)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_temp_sampler));
      __pyx_v_temp_sampler = ((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "GatEngine.pyx":575
 * 
 *                 # sample a position from current list of sampled segments
 *                 start, end, overlap = temp_sampler.sample( 1 )             # <<<<<<<<<<<<<<
 * 
 *                 # causes a potential bias for overlapping segments:
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *)__pyx_v_temp_sampler->__pyx_vtab)->sample(__pyx_v_temp_sampler, 1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_7 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 2; __pyx_t_1 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_10), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_7 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L12_unpacking_done:;
      }
      __pyx_t_11 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_12 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_6); if (unlikely((__pyx_t_12 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_start = __pyx_t_11;
      __pyx_v_end = __pyx_t_12;
      __pyx_v_overlap = __pyx_t_13;

      /* "GatEngine.pyx":582
 *                 unintersected_segments.trim_ends( start,
 *                                                   -true_remaining,
 *                                                   numpy.random.randint( 0,2) )             # <<<<<<<<<<<<<<
 * 
 *                 # trimming might remove residues outside the workspace
 */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__randint); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_14 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_unintersected_segments->__pyx_vtab)->trim_ends(__pyx_v_unintersected_segments, __pyx_v_start, (-__pyx_v_true_remaining), __pyx_t_14, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GatEngine.pyx":586
 *                 # trimming might remove residues outside the workspace
 *                 # hence - recompute true_remaining by going back to loop.
 *                 true_remaining = 1             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_v_true_remaining = 1;

      /* "GatEngine.pyx":587
 *                 # hence - recompute true_remaining by going back to loop.
 *                 true_remaining = 1
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             # sample a position until we get a nonzero overlap
 */
      goto __pyx_L6_continue;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "GatEngine.pyx":590
 * 
 *             # sample a position until we get a nonzero overlap
 *             start, end, overlap = sls.sample( length )             # <<<<<<<<<<<<<<
 * 
 *             sampled_segment = Segment( start, end )
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *)__pyx_v_sls->__pyx_vtab)->sample(__pyx_v_sls, __pyx_v_length, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 2; __pyx_t_3 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_10), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L14_unpacking_done;
      __pyx_L13_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L14_unpacking_done:;
    }
    __pyx_t_12 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_12 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_6); if (unlikely((__pyx_t_11 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_start = __pyx_t_12;
    __pyx_v_end = __pyx_t_11;
    __pyx_v_overlap = __pyx_t_13;

    /* "GatEngine.pyx":592
 *             start, end, overlap = sls.sample( length )
 * 
 *             sampled_segment = Segment( start, end )             # <<<<<<<<<<<<<<
 * 
 *             if true_remaining > 0:
 */
    __pyx_t_15.start = __pyx_v_start;
    __pyx_t_15.end = __pyx_v_end;
    __pyx_v_sampled_segment = __pyx_t_15;

    /* "GatEngine.pyx":594
 *             sampled_segment = Segment( start, end )
 * 
 *             if true_remaining > 0:             # <<<<<<<<<<<<<<
 *                 sampled_segments._add( sampled_segment )
 *                 remaining -= overlap
 */
    __pyx_t_9 = (__pyx_v_true_remaining > 0);
    if (__pyx_t_9) {

      /* "GatEngine.pyx":595
 * 
 *             if true_remaining > 0:
 *                 sampled_segments._add( sampled_segment )             # <<<<<<<<<<<<<<
 *                 remaining -= overlap
 * 
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sampled_segments->__pyx_vtab)->_add(__pyx_v_sampled_segments, __pyx_v_sampled_segment); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GatEngine.pyx":596
 *             if true_remaining > 0:
 *                 sampled_segments._add( sampled_segment )
 *                 remaining -= overlap             # <<<<<<<<<<<<<<
 * 
 *         self.nunsuccessful_rounds = nunsuccessful_rounds
 */
      __pyx_v_remaining = (__pyx_v_remaining - __pyx_v_overlap);
      goto __pyx_L15;
    }
    __pyx_L15:;
    __pyx_L6_continue:;
  }

  /* "GatEngine.pyx":598
 *                 remaining -= overlap
 * 
 *         self.nunsuccessful_rounds = nunsuccessful_rounds             # <<<<<<<<<<<<<<
 * 
 *         # merge overlapping/adjacent
 */
  __pyx_v_self->nunsuccessful_rounds = __pyx_v_nunsuccessful_rounds;

  /* "GatEngine.pyx":601
 * 
 *         # merge overlapping/adjacent
 *         intersected_segments = SegmentList( clone = unintersected_segments )             # <<<<<<<<<<<<<<
 *         intersected_segments.merge( 0 )
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_unintersected_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_intersected_segments));
  __pyx_v_intersected_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":602
 *         # merge overlapping/adjacent
 *         intersected_segments = SegmentList( clone = unintersected_segments )
 *         intersected_segments.merge( 0 )             # <<<<<<<<<<<<<<
 * 
 *         # remove all segments outside workspace
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_intersected_segments->__pyx_vtab)->merge(__pyx_v_intersected_segments, 0, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":605
 * 
 *         # remove all segments outside workspace
 *         intersected_segments.filter( workspace )             # <<<<<<<<<<<<<<
 * 
 *         assert intersected_segments.sum() > 0
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_intersected_segments->__pyx_vtab)->filter(__pyx_v_intersected_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":607
 *         intersected_segments.filter( workspace )
 * 
 *         assert intersected_segments.sum() > 0             # <<<<<<<<<<<<<<
 *         return intersected_segments
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_intersected_segments->__pyx_vtab)->sum(__pyx_v_intersected_segments, 0) > 0))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":608
 * 
 *         assert intersected_segments.sum() > 0
 *         return intersected_segments             # <<<<<<<<<<<<<<
 * 
 * def buildSamplerAnnotator( *args ):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_intersected_segments));
  __pyx_r = __pyx_v_intersected_segments;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("GatEngine.SamplerAnnotator.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sampled_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_unintersected_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_intersected_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_sls);
  __Pyx_XDECREF((PyObject *)__pyx_v_temp_sampler);
  __Pyx_XDECREF(__pyx_v_histogram);
  __Pyx_XDECREF(__pyx_v_bucket_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_hs);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_16SamplerAnnotator_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_16SamplerAnnotator_4sample[] = "SamplerAnnotator.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\nreturn a sampled list of segments.";
static PyObject *__pyx_pw_9GatEngine_16SamplerAnnotator_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerAnnotator.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_16SamplerAnnotator_4sample(((struct __pyx_obj_9GatEngine_SamplerAnnotator *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":478
 *                                         self.nunsuccessful_rounds ) )
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                               SegmentList segments,
 *                               SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_16SamplerAnnotator_4sample(struct __pyx_obj_9GatEngine_SamplerAnnotator *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerAnnotator *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerAnnotator.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_1buildSamplerAnnotator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_buildSamplerAnnotator[] = "buildSamplerAnnotator(*args)\nunpickling - return a rebuild SamplerAnnotator object.";
static PyMethodDef __pyx_mdef_9GatEngine_1buildSamplerAnnotator = {__Pyx_NAMESTR("buildSamplerAnnotator"), (PyCFunction)__pyx_pw_9GatEngine_1buildSamplerAnnotator, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_buildSamplerAnnotator)};
static PyObject *__pyx_pw_9GatEngine_1buildSamplerAnnotator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildSamplerAnnotator (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildSamplerAnnotator", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_buildSamplerAnnotator(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":610
 *         return intersected_segments
 * 
 * def buildSamplerAnnotator( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )
 */

static PyObject *__pyx_pf_9GatEngine_buildSamplerAnnotator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildSamplerAnnotator", 0);

  /* "GatEngine.pyx":612
 * def buildSamplerAnnotator( *args ):
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SamplerAnnotator)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildSamplerAnnotator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_15SamplerSegments_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_15SamplerSegments_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bucket_size = 0;
  PyObject *__pyx_v_nbuckets = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bucket_size,&__pyx_n_s__nbuckets,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_int_1);
    values[1] = ((PyObject *)__pyx_int_100000);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bucket_size);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbuckets);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bucket_size = values[0];
    __pyx_v_nbuckets = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerSegments.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_15SamplerSegments___init__(((struct __pyx_obj_9GatEngine_SamplerSegments *)__pyx_v_self), __pyx_v_bucket_size, __pyx_v_nbuckets);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":652
 *     cdef Position nbuckets
 * 
 *     def __init__( self, bucket_size = 1, nbuckets = 100000 ):             # <<<<<<<<<<<<<<
 * 
 *         self.bucket_size = bucket_size
 */

static int __pyx_pf_9GatEngine_15SamplerSegments___init__(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":654
 *     def __init__( self, bucket_size = 1, nbuckets = 100000 ):
 * 
 *         self.bucket_size = bucket_size             # <<<<<<<<<<<<<<
 *         self.nbuckets = nbuckets
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_bucket_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->bucket_size = __pyx_t_1;

  /* "GatEngine.pyx":655
 * 
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_nbuckets); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nbuckets = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.SamplerSegments.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15SamplerSegments_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_15SamplerSegments_2__reduce__[] = "SamplerSegments.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_15SamplerSegments_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15SamplerSegments_2__reduce__(((struct __pyx_obj_9GatEngine_SamplerSegments *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":657
 *         self.nbuckets = nbuckets
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildSamplerSegments, (self.bucket_size,
 *                                        self.nbuckets ))
 */

static PyObject *__pyx_pf_9GatEngine_15SamplerSegments_2__reduce__(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":658
 * 
 *     def __reduce__(self):
 *         return (buildSamplerSegments, (self.bucket_size,             # <<<<<<<<<<<<<<
 *                                        self.nbuckets ))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "GatEngine.pyx":659
 *     def __reduce__(self):
 *         return (buildSamplerSegments, (self.bucket_size,
 *                                        self.nbuckets ))             # <<<<<<<<<<<<<<
 * 
 *     cpdef SegmentList sample( self,
 */
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.SamplerSegments.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":661
 *                                        self.nbuckets ))
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_15SamplerSegments_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_15SamplerSegments_sample(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_sls = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = NULL;
  PyObject *__pyx_v_histogram = NULL;
  PyObject *__pyx_v_bucket_size = NULL;
  struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_hs = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_start = NULL;
  PyObject *__pyx_v_end = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_overlap = NULL;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_11;
  __pyx_t_14GatSegmentList_Position __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_15SamplerSegments_5sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":670
 *         cdef SegmentList sample
 * 
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         sample = SegmentList( allocate = len(segments) )
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":672
 *         assert workspace.isNormalized, "workspace is not normalized"
 * 
 *         sample = SegmentList( allocate = len(segments) )             # <<<<<<<<<<<<<<
 * 
 *         # collect all segments in workspace
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__allocate), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":675
 * 
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         working_segments.filter( workspace )
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":676
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )             # <<<<<<<<<<<<<<
 * 
 *         if len(working_segments) == 0:
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->filter(__pyx_v_working_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":678
 *         working_segments.filter( workspace )
 * 
 *         if len(working_segments) == 0:             # <<<<<<<<<<<<<<
 *             return sample
 * 
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_5 == 0);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":679
 * 
 *         if len(working_segments) == 0:
 *             return sample             # <<<<<<<<<<<<<<
 * 
 *         # build length histogram
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_sample));
    __pyx_r = __pyx_v_sample;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":682
 * 
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                             self.nbuckets )
 *         hs = HistogramSampler( histogram, bucket_size )
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_working_segments), __pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "GatEngine.pyx":683
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,
 *                                                             self.nbuckets )             # <<<<<<<<<<<<<<
 *         hs = HistogramSampler( histogram, bucket_size )
 * 
 */
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L5_unpacking_done:;
  }

  /* "GatEngine.pyx":682
 * 
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                             self.nbuckets )
 *         hs = HistogramSampler( histogram, bucket_size )
 */
  __pyx_v_histogram = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_bucket_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":684
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,
 *                                                             self.nbuckets )
 *         hs = HistogramSampler( histogram, bucket_size )             # <<<<<<<<<<<<<<
 * 
 *         # create segment sampler
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_histogram);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_histogram);
  __Pyx_GIVEREF(__pyx_v_histogram);
  __Pyx_INCREF(__pyx_v_bucket_size);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_bucket_size);
  __Pyx_GIVEREF(__pyx_v_bucket_size);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_HistogramSampler)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_hs = ((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":687
 * 
 *         # create segment sampler
 *         sls = SegmentListSampler( workspace )             # <<<<<<<<<<<<<<
 * 
 *         for x in xrange( len(segments) ):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SegmentListSampler)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sls = ((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":689
 *         sls = SegmentListSampler( workspace )
 * 
 *         for x in xrange( len(segments) ):             # <<<<<<<<<<<<<<
 * 
 *             # Sample a segment length from the histogram
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_xrange, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":692
 * 
 *             # Sample a segment length from the histogram
 *             length = hs.sample()             # <<<<<<<<<<<<<<
 *             assert length > 0
 * 
 */
    __pyx_v_length = ((struct __pyx_vtabstruct_9GatEngine_HistogramSampler *)__pyx_v_hs->__pyx_vtab)->sample(__pyx_v_hs, 0);

    /* "GatEngine.pyx":693
 *             # Sample a segment length from the histogram
 *             length = hs.sample()
 *             assert length > 0             # <<<<<<<<<<<<<<
 * 
 *             # sample a position until we get a nonzero overlap
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_length > 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "GatEngine.pyx":696
 * 
 *             # sample a position until we get a nonzero overlap
 *             start, end, overlap = sls.sample( length )             # <<<<<<<<<<<<<<
 * 
 *             sample._add( Segment( start, end ) )
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *)__pyx_v_sls->__pyx_vtab)->sample(__pyx_v_sls, __pyx_v_length, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 2; __pyx_t_9 = __pyx_t_7(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_10), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L9_unpacking_done;
      __pyx_L8_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L9_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_start);
    __pyx_v_start = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_v_end);
    __pyx_v_end = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_v_overlap);
    __pyx_v_overlap = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "GatEngine.pyx":698
 *             start, end, overlap = sls.sample( length )
 * 
 *             sample._add( Segment( start, end ) )             # <<<<<<<<<<<<<<
 * 
 *         return sample
 */
    __pyx_t_12 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_start); if (unlikely((__pyx_t_12 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11.start = __pyx_t_12;
    __pyx_t_12 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_end); if (unlikely((__pyx_t_12 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11.end = __pyx_t_12;
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_11); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":700
 *             sample._add( Segment( start, end ) )
 * 
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * def buildSamplerSegments( *args ):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("GatEngine.SamplerSegments.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sls);
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF(__pyx_v_histogram);
  __Pyx_XDECREF(__pyx_v_bucket_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_hs);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_overlap);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15SamplerSegments_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_15SamplerSegments_4sample[] = "SamplerSegments.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\nreturn a sampled list of segments.";
static PyObject *__pyx_pw_9GatEngine_15SamplerSegments_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerSegments.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_15SamplerSegments_4sample(((struct __pyx_obj_9GatEngine_SamplerSegments *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":661
 *                                        self.nbuckets ))
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_15SamplerSegments_4sample(struct __pyx_obj_9GatEngine_SamplerSegments *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerSegments *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerSegments.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_3buildSamplerSegments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_2buildSamplerSegments[] = "buildSamplerSegments(*args)\nunpickling - return a rebuild SamplerAnnotator object.";
static PyMethodDef __pyx_mdef_9GatEngine_3buildSamplerSegments = {__Pyx_NAMESTR("buildSamplerSegments"), (PyCFunction)__pyx_pw_9GatEngine_3buildSamplerSegments, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_2buildSamplerSegments)};
static PyObject *__pyx_pw_9GatEngine_3buildSamplerSegments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildSamplerSegments (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildSamplerSegments", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_2buildSamplerSegments(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":702
 *         return sample
 * 
 * def buildSamplerSegments( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )
 */

static PyObject *__pyx_pf_9GatEngine_2buildSamplerSegments(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildSamplerSegments", 0);

  /* "GatEngine.pyx":704
 * def buildSamplerSegments( *args ):
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SamplerAnnotator)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildSamplerSegments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_17SamplerBruteForce_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_17SamplerBruteForce_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bucket_size = 0;
  PyObject *__pyx_v_nbuckets = 0;
  PyObject *__pyx_v_ntries_inner = 0;
  PyObject *__pyx_v_ntries_outer = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bucket_size,&__pyx_n_s__nbuckets,&__pyx_n_s__ntries_inner,&__pyx_n_s__ntries_outer,0};
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)__pyx_int_1);
    values[1] = ((PyObject *)__pyx_int_100000);
    values[2] = ((PyObject *)__pyx_int_100);
    values[3] = ((PyObject *)__pyx_int_10);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bucket_size);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbuckets);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ntries_inner);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ntries_outer);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bucket_size = values[0];
    __pyx_v_nbuckets = values[1];
    __pyx_v_ntries_inner = values[2];
    __pyx_v_ntries_outer = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerBruteForce.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_17SamplerBruteForce___init__(((struct __pyx_obj_9GatEngine_SamplerBruteForce *)__pyx_v_self), __pyx_v_bucket_size, __pyx_v_nbuckets, __pyx_v_ntries_inner, __pyx_v_ntries_outer);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":739
 *     cdef int ntries_outer
 * 
 *     def __init__( self,             # <<<<<<<<<<<<<<
 *                   bucket_size = 1,
 *                   nbuckets = 100000,
 */

static int __pyx_pf_9GatEngine_17SamplerBruteForce___init__(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets, PyObject *__pyx_v_ntries_inner, PyObject *__pyx_v_ntries_outer) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":745
 *                   ntries_outer = 10 ):
 * 
 *         self.bucket_size = bucket_size             # <<<<<<<<<<<<<<
 *         self.nbuckets = nbuckets
 *         self.ntries_inner = ntries_inner
 */
  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_bucket_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->bucket_size = __pyx_t_1;

  /* "GatEngine.pyx":746
 * 
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets             # <<<<<<<<<<<<<<
 *         self.ntries_inner = ntries_inner
 *         self.ntries_outer = ntries_outer
 */
  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_nbuckets); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nbuckets = __pyx_t_1;

  /* "GatEngine.pyx":747
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets
 *         self.ntries_inner = ntries_inner             # <<<<<<<<<<<<<<
 *         self.ntries_outer = ntries_outer
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_ntries_inner); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->ntries_inner = __pyx_t_2;

  /* "GatEngine.pyx":748
 *         self.nbuckets = nbuckets
 *         self.ntries_inner = ntries_inner
 *         self.ntries_outer = ntries_outer             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_ntries_outer); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->ntries_outer = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.SamplerBruteForce.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17SamplerBruteForce_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17SamplerBruteForce_2__reduce__[] = "SamplerBruteForce.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_17SamplerBruteForce_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17SamplerBruteForce_2__reduce__(((struct __pyx_obj_9GatEngine_SamplerBruteForce *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":750
 *         self.ntries_outer = ntries_outer
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildSamplerBruteForce, (self.bucket_size,
 *                                          self.nbuckets,
 */

static PyObject *__pyx_pf_9GatEngine_17SamplerBruteForce_2__reduce__(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":751
 * 
 *     def __reduce__(self):
 *         return (buildSamplerBruteForce, (self.bucket_size,             # <<<<<<<<<<<<<<
 *                                          self.nbuckets,
 *                                          self.ntries_inner,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "GatEngine.pyx":752
 *     def __reduce__(self):
 *         return (buildSamplerBruteForce, (self.bucket_size,
 *                                          self.nbuckets,             # <<<<<<<<<<<<<<
 *                                          self.ntries_inner,
 *                                          self.ntries_outer) )
 */
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "GatEngine.pyx":753
 *         return (buildSamplerBruteForce, (self.bucket_size,
 *                                          self.nbuckets,
 *                                          self.ntries_inner,             # <<<<<<<<<<<<<<
 *                                          self.ntries_outer) )
 * 
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_self->ntries_inner); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "GatEngine.pyx":754
 *                                          self.nbuckets,
 *                                          self.ntries_inner,
 *                                          self.ntries_outer) )             # <<<<<<<<<<<<<<
 * 
 *     cpdef SegmentList sample( self,
 */
  __pyx_t_5 = PyInt_FromLong(__pyx_v_self->ntries_outer); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_t_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_r = ((PyObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.SamplerBruteForce.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":756
 *                                          self.ntries_outer) )
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_17SamplerBruteForce_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_17SamplerBruteForce_sample(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  __pyx_t_14GatSegmentList_Position __pyx_v_start;
  __pyx_t_14GatSegmentList_Position __pyx_v_end;
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  struct __pyx_obj_9GatEngine_SegmentListSampler *__pyx_v_sls = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = NULL;
  PyObject *__pyx_v_histogram = NULL;
  PyObject *__pyx_v_bucket_size = NULL;
  struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_hs = NULL;
  int __pyx_v_ntries_outer;
  int __pyx_v_ntries_inner;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_remaining;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_overlap;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_12;
  __pyx_t_14GatSegmentList_Position __pyx_t_13;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_t_14;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_17SamplerBruteForce_5sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":765
 *         cdef SegmentList sample
 * 
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         sample = SegmentList( allocate = len(segments) )
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":767
 *         assert workspace.isNormalized, "workspace is not normalized"
 * 
 *         sample = SegmentList( allocate = len(segments) )             # <<<<<<<<<<<<<<
 * 
 *         # collect all segments in workspace
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__allocate), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":770
 * 
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         working_segments.filter( workspace )
 * 
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":771
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )             # <<<<<<<<<<<<<<
 * 
 *         if len(working_segments) == 0:
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->filter(__pyx_v_working_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":773
 *         working_segments.filter( workspace )
 * 
 *         if len(working_segments) == 0:             # <<<<<<<<<<<<<<
 *             return sample
 * 
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_5 == 0);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":774
 * 
 *         if len(working_segments) == 0:
 *             return sample             # <<<<<<<<<<<<<<
 * 
 *         # build length histogram
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_sample));
    __pyx_r = __pyx_v_sample;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":777
 * 
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                                          self.nbuckets )
 *         hs = HistogramSampler( histogram, bucket_size )
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_working_segments), __pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "GatEngine.pyx":778
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,
 *                                                                          self.nbuckets )             # <<<<<<<<<<<<<<
 *         hs = HistogramSampler( histogram, bucket_size )
 * 
 */
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L5_unpacking_done:;
  }

  /* "GatEngine.pyx":777
 * 
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                                          self.nbuckets )
 *         hs = HistogramSampler( histogram, bucket_size )
 */
  __pyx_v_histogram = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_bucket_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":779
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,
 *                                                                          self.nbuckets )
 *         hs = HistogramSampler( histogram, bucket_size )             # <<<<<<<<<<<<<<
 * 
 *         # create segment sampler
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_histogram);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_histogram);
  __Pyx_GIVEREF(__pyx_v_histogram);
  __Pyx_INCREF(__pyx_v_bucket_size);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_bucket_size);
  __Pyx_GIVEREF(__pyx_v_bucket_size);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_HistogramSampler)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_hs = ((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":782
 * 
 *         # create segment sampler
 *         sls = SegmentListSampler( workspace )             # <<<<<<<<<<<<<<
 * 
 *         cdef int ntries_outer = self.ntries_outer
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SegmentListSampler)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sls = ((struct __pyx_obj_9GatEngine_SegmentListSampler *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":784
 *         sls = SegmentListSampler( workspace )
 * 
 *         cdef int ntries_outer = self.ntries_outer             # <<<<<<<<<<<<<<
 *         cdef int ntries_inner
 *         cdef PositionDifference remaining, overlap
 */
  __pyx_t_8 = __pyx_v_self->ntries_outer;
  __pyx_v_ntries_outer = __pyx_t_8;

  /* "GatEngine.pyx":788
 *         cdef PositionDifference remaining, overlap
 * 
 *         while ntries_outer > 0:             # <<<<<<<<<<<<<<
 * 
 *             sample.clear()
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_ntries_outer > 0);
    if (!__pyx_t_4) break;

    /* "GatEngine.pyx":790
 *         while ntries_outer > 0:
 * 
 *             sample.clear()             # <<<<<<<<<<<<<<
 * 
 *             remaining = segments.sum()
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->clear(__pyx_v_sample, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "GatEngine.pyx":792
 *             sample.clear()
 * 
 *             remaining = segments.sum()             # <<<<<<<<<<<<<<
 *             ntries_inner = self.ntries_inner
 *             # print "starting inner tries"
 */
    __pyx_v_remaining = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segments->__pyx_vtab)->sum(__pyx_v_segments, 0);

    /* "GatEngine.pyx":793
 * 
 *             remaining = segments.sum()
 *             ntries_inner = self.ntries_inner             # <<<<<<<<<<<<<<
 *             # print "starting inner tries"
 * 
 */
    __pyx_t_8 = __pyx_v_self->ntries_inner;
    __pyx_v_ntries_inner = __pyx_t_8;

    /* "GatEngine.pyx":796
 *             # print "starting inner tries"
 * 
 *             while remaining > 0 and ntries_inner > 0:             # <<<<<<<<<<<<<<
 * 
 *                 # Sample a segment length from the histogram
 */
    while (1) {
      __pyx_t_4 = (__pyx_v_remaining > 0);
      if (__pyx_t_4) {
        __pyx_t_9 = (__pyx_v_ntries_inner > 0);
        __pyx_t_10 = __pyx_t_9;
      } else {
        __pyx_t_10 = __pyx_t_4;
      }
      if (!__pyx_t_10) break;

      /* "GatEngine.pyx":799
 * 
 *                 # Sample a segment length from the histogram
 *                 length = hs.sample()             # <<<<<<<<<<<<<<
 *                 assert length > 0
 * 
 */
      __pyx_v_length = ((struct __pyx_vtabstruct_9GatEngine_HistogramSampler *)__pyx_v_hs->__pyx_vtab)->sample(__pyx_v_hs, 0);

      /* "GatEngine.pyx":800
 *                 # Sample a segment length from the histogram
 *                 length = hs.sample()
 *                 assert length > 0             # <<<<<<<<<<<<<<
 * 
 *                 # sample a position until we get a nonzero overlap
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(__pyx_v_length > 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "GatEngine.pyx":803
 * 
 *                 # sample a position until we get a nonzero overlap
 *                 start, end, overlap = sls.sample( length )             # <<<<<<<<<<<<<<
 * 
 *                 # print str(sample), start, end, overlap, remaining
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_9GatEngine_SegmentListSampler *)__pyx_v_sls->__pyx_vtab)->sample(__pyx_v_sls, __pyx_v_length, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_7 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_1 = __pyx_t_7(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 2; __pyx_t_3 = __pyx_t_7(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L11_unpacking_done;
        __pyx_L10_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_7 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L11_unpacking_done:;
      }
      __pyx_t_12 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_1); if (unlikely((__pyx_t_12 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_13 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_6); if (unlikely((__pyx_t_13 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_14 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_start = __pyx_t_12;
      __pyx_v_end = __pyx_t_13;
      __pyx_v_overlap = __pyx_t_14;

      /* "GatEngine.pyx":807
 *                 # print str(sample), start, end, overlap, remaining
 * 
 *                 if overlap > remaining:             # <<<<<<<<<<<<<<
 *                     ntries_inner -= 1
 *                     continue
 */
      __pyx_t_10 = (__pyx_v_overlap > __pyx_v_remaining);
      if (__pyx_t_10) {

        /* "GatEngine.pyx":808
 * 
 *                 if overlap > remaining:
 *                     ntries_inner -= 1             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
        __pyx_v_ntries_inner = (__pyx_v_ntries_inner - 1);

        /* "GatEngine.pyx":809
 *                 if overlap > remaining:
 *                     ntries_inner -= 1
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 if sample.overlapWithRange( start, end ):
 */
        goto __pyx_L8_continue;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "GatEngine.pyx":811
 *                     continue
 * 
 *                 if sample.overlapWithRange( start, end ):             # <<<<<<<<<<<<<<
 *                     ntries_inner -= 1
 *                     continue
 */
      __pyx_t_13 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->overlapWithRange(__pyx_v_sample, __pyx_v_start, __pyx_v_end, 0);
      if (__pyx_t_13) {

        /* "GatEngine.pyx":812
 * 
 *                 if sample.overlapWithRange( start, end ):
 *                     ntries_inner -= 1             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
        __pyx_v_ntries_inner = (__pyx_v_ntries_inner - 1);

        /* "GatEngine.pyx":813
 *                 if sample.overlapWithRange( start, end ):
 *                     ntries_inner -= 1
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 sample._add( Segment( start, end ) )
 */
        goto __pyx_L8_continue;
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "GatEngine.pyx":815
 *                     continue
 * 
 *                 sample._add( Segment( start, end ) )             # <<<<<<<<<<<<<<
 *                 # required in order to sort samples
 *                 sample.normalize()
 */
      __pyx_t_15.start = __pyx_v_start;
      __pyx_t_15.end = __pyx_v_end;
      __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_15); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":817
 *                 sample._add( Segment( start, end ) )
 *                 # required in order to sort samples
 *                 sample.normalize()             # <<<<<<<<<<<<<<
 * 
 *                 # print "adding", start, end, str(sample)
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->normalize(__pyx_v_sample, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":821
 *                 # print "adding", start, end, str(sample)
 * 
 *                 ntries_inner = self.ntries_inner             # <<<<<<<<<<<<<<
 * 
 *                 remaining -= overlap
 */
      __pyx_t_8 = __pyx_v_self->ntries_inner;
      __pyx_v_ntries_inner = __pyx_t_8;

      /* "GatEngine.pyx":823
 *                 ntries_inner = self.ntries_inner
 * 
 *                 remaining -= overlap             # <<<<<<<<<<<<<<
 * 
 *             if ntries_inner > 0:
 */
      __pyx_v_remaining = (__pyx_v_remaining - __pyx_v_overlap);
      __pyx_L8_continue:;
    }

    /* "GatEngine.pyx":825
 *                 remaining -= overlap
 * 
 *             if ntries_inner > 0:             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
    __pyx_t_10 = (__pyx_v_ntries_inner > 0);
    if (__pyx_t_10) {

      /* "GatEngine.pyx":826
 * 
 *             if ntries_inner > 0:
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             ntries_outer -= 1
 */
      goto __pyx_L7_break;
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "GatEngine.pyx":828
 *                 break
 * 
 *             ntries_outer -= 1             # <<<<<<<<<<<<<<
 * 
 *         if ntries_outer == 0:
 */
    __pyx_v_ntries_outer = (__pyx_v_ntries_outer - 1);
  }
  __pyx_L7_break:;

  /* "GatEngine.pyx":830
 *             ntries_outer -= 1
 * 
 *         if ntries_outer == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError( "sampling did not converge: %s" % str(sample))
 * 
 */
  __pyx_t_10 = (__pyx_v_ntries_outer == 0);
  if (__pyx_t_10) {

    /* "GatEngine.pyx":831
 * 
 *         if ntries_outer == 0:
 *             raise ValueError( "sampling did not converge: %s" % str(sample))             # <<<<<<<<<<<<<<
 * 
 *         return sample
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_sample));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_sample));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_sample));
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "GatEngine.pyx":833
 *             raise ValueError( "sampling did not converge: %s" % str(sample))
 * 
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * def buildSamplerBruteForce( *args ):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("GatEngine.SamplerBruteForce.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sls);
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF(__pyx_v_histogram);
  __Pyx_XDECREF(__pyx_v_bucket_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_hs);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17SamplerBruteForce_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_17SamplerBruteForce_4sample[] = "SamplerBruteForce.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\nreturn a sampled list of segments.";
static PyObject *__pyx_pw_9GatEngine_17SamplerBruteForce_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerBruteForce.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_17SamplerBruteForce_4sample(((struct __pyx_obj_9GatEngine_SamplerBruteForce *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":756
 *                                          self.ntries_outer) )
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_17SamplerBruteForce_4sample(struct __pyx_obj_9GatEngine_SamplerBruteForce *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerBruteForce *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerBruteForce.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_5buildSamplerBruteForce(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_4buildSamplerBruteForce[] = "buildSamplerBruteForce(*args)\nunpickling - return a rebuild SamplerAnnotator object.";
static PyMethodDef __pyx_mdef_9GatEngine_5buildSamplerBruteForce = {__Pyx_NAMESTR("buildSamplerBruteForce"), (PyCFunction)__pyx_pw_9GatEngine_5buildSamplerBruteForce, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_4buildSamplerBruteForce)};
static PyObject *__pyx_pw_9GatEngine_5buildSamplerBruteForce(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildSamplerBruteForce (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildSamplerBruteForce", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_4buildSamplerBruteForce(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":835
 *         return sample
 * 
 * def buildSamplerBruteForce( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerBruteForce( *args )
 */

static PyObject *__pyx_pf_9GatEngine_4buildSamplerBruteForce(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildSamplerBruteForce", 0);

  /* "GatEngine.pyx":837
 * def buildSamplerBruteForce( *args ):
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerBruteForce( *args )             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SamplerBruteForce)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildSamplerBruteForce", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_14SamplerUniform_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_14SamplerUniform_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_increment = 0;
  PyObject *__pyx_v_bucket_size = 0;
  PyObject *__pyx_v_nbuckets = 0;
  PyObject *__pyx_v_current_orientation = 0;
  PyObject *__pyx_v_current_workspace = 0;
  PyObject *__pyx_v_current_position = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__increment,&__pyx_n_s__bucket_size,&__pyx_n_s__nbuckets,&__pyx_n_s__current_orientation,&__pyx_n_s__current_workspace,&__pyx_n_s__current_position,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    values[2] = ((PyObject *)__pyx_int_100000);
    values[3] = ((PyObject *)__pyx_int_0);
    values[4] = ((PyObject *)__pyx_int_0);
    values[5] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__increment)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bucket_size);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbuckets);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__current_orientation);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__current_workspace);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__current_position);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_increment = values[0];
    __pyx_v_bucket_size = values[1];
    __pyx_v_nbuckets = values[2];
    __pyx_v_current_orientation = values[3];
    __pyx_v_current_workspace = values[4];
    __pyx_v_current_position = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerUniform.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_14SamplerUniform___init__(((struct __pyx_obj_9GatEngine_SamplerUniform *)__pyx_v_self), __pyx_v_increment, __pyx_v_bucket_size, __pyx_v_nbuckets, __pyx_v_current_orientation, __pyx_v_current_workspace, __pyx_v_current_position);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":868
 *     cdef int current_orientation
 * 
 *     def __init__( self,             # <<<<<<<<<<<<<<
 *                   increment,
 *                   bucket_size = 1,
 */

static int __pyx_pf_9GatEngine_14SamplerUniform___init__(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self, PyObject *__pyx_v_increment, PyObject *__pyx_v_bucket_size, PyObject *__pyx_v_nbuckets, PyObject *__pyx_v_current_orientation, PyObject *__pyx_v_current_workspace, PyObject *__pyx_v_current_position) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __pyx_t_14GatSegmentList_Position __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":875
 *                   current_workspace = 0,
 *                   current_position = 0):
 *         self.current_orientation = current_orientation             # <<<<<<<<<<<<<<
 *         self.current_workspace = current_workspace
 *         self.current_position = current_position
 */
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_current_orientation); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->current_orientation = __pyx_t_1;

  /* "GatEngine.pyx":876
 *                   current_position = 0):
 *         self.current_orientation = current_orientation
 *         self.current_workspace = current_workspace             # <<<<<<<<<<<<<<
 *         self.current_position = current_position
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_current_workspace); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->current_workspace = __pyx_t_2;

  /* "GatEngine.pyx":877
 *         self.current_orientation = current_orientation
 *         self.current_workspace = current_workspace
 *         self.current_position = current_position             # <<<<<<<<<<<<<<
 * 
 *         self.bucket_size = bucket_size
 */
  __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_current_position); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->current_position = __pyx_t_2;

  /* "GatEngine.pyx":879
 *         self.current_position = current_position
 * 
 *         self.bucket_size = bucket_size             # <<<<<<<<<<<<<<
 *         self.nbuckets = nbuckets
 *         self.increment = increment
 */
  __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_bucket_size); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->bucket_size = __pyx_t_2;

  /* "GatEngine.pyx":880
 * 
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets             # <<<<<<<<<<<<<<
 *         self.increment = increment
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_nbuckets); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->nbuckets = __pyx_t_2;

  /* "GatEngine.pyx":881
 *         self.bucket_size = bucket_size
 *         self.nbuckets = nbuckets
 *         self.increment = increment             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_increment); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->increment = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.SamplerUniform.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_14SamplerUniform_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_14SamplerUniform_2__reduce__[] = "SamplerUniform.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_14SamplerUniform_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_14SamplerUniform_2__reduce__(((struct __pyx_obj_9GatEngine_SamplerUniform *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":883
 *         self.increment = increment
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildSamplerUniform, (self.increment,
 *                                       self.bucket_size,
 */

static PyObject *__pyx_pf_9GatEngine_14SamplerUniform_2__reduce__(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":884
 * 
 *     def __reduce__(self):
 *         return (buildSamplerUniform, (self.increment,             # <<<<<<<<<<<<<<
 *                                       self.bucket_size,
 *                                       self.nbuckets,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__buildSamplerUniform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->increment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "GatEngine.pyx":885
 *     def __reduce__(self):
 *         return (buildSamplerUniform, (self.increment,
 *                                       self.bucket_size,             # <<<<<<<<<<<<<<
 *                                       self.nbuckets,
 *                                       self.current_orientation,
 */
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "GatEngine.pyx":886
 *         return (buildSamplerUniform, (self.increment,
 *                                       self.bucket_size,
 *                                       self.nbuckets,             # <<<<<<<<<<<<<<
 *                                       self.current_orientation,
 *                                       self.current_workspace,
 */
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "GatEngine.pyx":887
 *                                       self.bucket_size,
 *                                       self.nbuckets,
 *                                       self.current_orientation,             # <<<<<<<<<<<<<<
 *                                       self.current_workspace,
 *                                       self.current_position) )
 */
  __pyx_t_5 = PyInt_FromLong(__pyx_v_self->current_orientation); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "GatEngine.pyx":888
 *                                       self.nbuckets,
 *                                       self.current_orientation,
 *                                       self.current_workspace,             # <<<<<<<<<<<<<<
 *                                       self.current_position) )
 * 
 */
  __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_self->current_workspace); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "GatEngine.pyx":889
 *                                       self.current_orientation,
 *                                       self.current_workspace,
 *                                       self.current_position) )             # <<<<<<<<<<<<<<
 * 
 *     cpdef SegmentList sample( self,
 */
  __pyx_t_7 = PyLong_FromUnsignedLong(__pyx_v_self->current_position); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_t_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
  __pyx_t_1 = 0;
  __pyx_t_8 = 0;
  __pyx_r = ((PyObject *)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.SamplerUniform.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":891
 *                                       self.current_position) )
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_14SamplerUniform_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_14SamplerUniform_sample(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  __pyx_t_14GatSegmentList_Position __pyx_v_increment;
  __pyx_t_14GatSegmentList_Position __pyx_v_start;
  __pyx_t_14GatSegmentList_Position __pyx_v_end;
  __pyx_t_14GatSegmentList_Position __pyx_v_x;
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  __pyx_t_14GatSegmentList_Position __pyx_v_added;
  __pyx_t_14GatSegmentList_Position __pyx_v_nsegments;
  __pyx_t_14GatSegmentList_Position __pyx_v_nworkspaces;
  __pyx_t_14GatSegmentList_Position __pyx_v_current_workspace;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = NULL;
  PyObject *__pyx_v_histogram = NULL;
  PyObject *__pyx_v_bucket_size = NULL;
  struct __pyx_obj_9GatEngine_HistogramSampler *__pyx_v_hs = NULL;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __pyx_t_14GatSegmentList_Position __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  __pyx_t_14GatSegmentList_Position __pyx_t_9;
  long __pyx_t_10;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_14SamplerUniform_5sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":895
 *                                            SegmentList workspace ):
 *         '''return a sampled list of segments.'''
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         cdef SegmentList sample
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":899
 *         cdef SegmentList sample
 *         cdef SegmentListSampler sls
 *         cdef Position increment = self.increment             # <<<<<<<<<<<<<<
 *         cdef Position start, end, x, length, i, added, nsegments, nworkspaces
 *         cdef Position current_offset, current_workspace
 */
  __pyx_t_5 = __pyx_v_self->increment;
  __pyx_v_increment = __pyx_t_5;

  /* "GatEngine.pyx":904
 * 
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         working_segments.filter( workspace )
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":905
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )             # <<<<<<<<<<<<<<
 * 
 *         # allocate sample large enough
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->filter(__pyx_v_working_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":908
 * 
 *         # allocate sample large enough
 *         sample = SegmentList( allocate = (len(workspace) / increment + workspace.sum() ) )             # <<<<<<<<<<<<<<
 * 
 *         if len(working_segments) == 0:
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_workspace)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_v_increment == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && unlikely(__pyx_v_increment == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_6))) {
    PyErr_Format(PyExc_OverflowError, "value too large to perform division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyInt_FromSsize_t((__Pyx_div_Py_ssize_t(__pyx_t_6, __pyx_v_increment) + ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_workspace->__pyx_vtab)->sum(__pyx_v_workspace, 0))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__allocate), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":910
 *         sample = SegmentList( allocate = (len(workspace) / increment + workspace.sum() ) )
 * 
 *         if len(working_segments) == 0:             # <<<<<<<<<<<<<<
 *             return sample
 * 
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_6 == 0);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":911
 * 
 *         if len(working_segments) == 0:
 *             return sample             # <<<<<<<<<<<<<<
 * 
 *         # build length histogram
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_sample));
    __pyx_r = __pyx_v_sample;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":914
 * 
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                                          self.nbuckets )
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_working_segments), __pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->bucket_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "GatEngine.pyx":915
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,
 *                                                                          self.nbuckets )             # <<<<<<<<<<<<<<
 * 
 *         hs = HistogramSampler( histogram, bucket_size )
 */
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->nbuckets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_7 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_7)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_7);
    index = 1; __pyx_t_1 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L5_unpacking_done:;
  }

  /* "GatEngine.pyx":914
 * 
 *         # build length histogram
 *         histogram, bucket_size = working_segments.getLengthDistribution( self.bucket_size,             # <<<<<<<<<<<<<<
 *                                                                          self.nbuckets )
 * 
 */
  __pyx_v_histogram = __pyx_t_7;
  __pyx_t_7 = 0;
  __pyx_v_bucket_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":917
 *                                                                          self.nbuckets )
 * 
 *         hs = HistogramSampler( histogram, bucket_size )             # <<<<<<<<<<<<<<
 * 
 *         sample = SegmentList( allocate = increment )
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_histogram);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_histogram);
  __Pyx_GIVEREF(__pyx_v_histogram);
  __Pyx_INCREF(__pyx_v_bucket_size);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_bucket_size);
  __Pyx_GIVEREF(__pyx_v_bucket_size);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_HistogramSampler)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_hs = ((struct __pyx_obj_9GatEngine_HistogramSampler *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":919
 *         hs = HistogramSampler( histogram, bucket_size )
 * 
 *         sample = SegmentList( allocate = increment )             # <<<<<<<<<<<<<<
 * 
 *         added = 0
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_increment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__allocate), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_sample));
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":921
 *         sample = SegmentList( allocate = increment )
 * 
 *         added = 0             # <<<<<<<<<<<<<<
 * 
 *         nsegments = len(working_segments)
 */
  __pyx_v_added = 0;

  /* "GatEngine.pyx":923
 *         added = 0
 * 
 *         nsegments = len(working_segments)             # <<<<<<<<<<<<<<
 *         nworkspaces = len(workspace)
 * 
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nsegments = __pyx_t_6;

  /* "GatEngine.pyx":924
 * 
 *         nsegments = len(working_segments)
 *         nworkspaces = len(workspace)             # <<<<<<<<<<<<<<
 * 
 *         x = self.current_position
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_workspace)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nworkspaces = __pyx_t_6;

  /* "GatEngine.pyx":926
 *         nworkspaces = len(workspace)
 * 
 *         x = self.current_position             # <<<<<<<<<<<<<<
 *         current_workspace = self.current_workspace
 *         start, end = workspace[current_workspace]
 */
  __pyx_t_5 = __pyx_v_self->current_position;
  __pyx_v_x = __pyx_t_5;

  /* "GatEngine.pyx":927
 * 
 *         x = self.current_position
 *         current_workspace = self.current_workspace             # <<<<<<<<<<<<<<
 *         start, end = workspace[current_workspace]
 * 
 */
  __pyx_t_5 = __pyx_v_self->current_workspace;
  __pyx_v_current_workspace = __pyx_t_5;

  /* "GatEngine.pyx":928
 *         x = self.current_position
 *         current_workspace = self.current_workspace
 *         start, end = workspace[current_workspace]             # <<<<<<<<<<<<<<
 * 
 *         while added < nsegments:
 */
  __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_workspace), __pyx_v_current_workspace, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_7);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_7 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L7_unpacking_done:;
  }
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_7); if (unlikely((__pyx_t_9 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_start = __pyx_t_5;
  __pyx_v_end = __pyx_t_9;

  /* "GatEngine.pyx":930
 *         start, end = workspace[current_workspace]
 * 
 *         while added < nsegments:             # <<<<<<<<<<<<<<
 * 
 *             while x > end:
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_added < __pyx_v_nsegments);
    if (!__pyx_t_4) break;

    /* "GatEngine.pyx":932
 *         while added < nsegments:
 * 
 *             while x > end:             # <<<<<<<<<<<<<<
 *                 x -= end
 *                 current_workspace = (current_workspace + 1) % nworkspaces
 */
    while (1) {
      __pyx_t_4 = (__pyx_v_x > __pyx_v_end);
      if (!__pyx_t_4) break;

      /* "GatEngine.pyx":933
 * 
 *             while x > end:
 *                 x -= end             # <<<<<<<<<<<<<<
 *                 current_workspace = (current_workspace + 1) % nworkspaces
 *                 start, end = workspace[current_workspace]
 */
      __pyx_v_x = (__pyx_v_x - __pyx_v_end);

      /* "GatEngine.pyx":934
 *             while x > end:
 *                 x -= end
 *                 current_workspace = (current_workspace + 1) % nworkspaces             # <<<<<<<<<<<<<<
 *                 start, end = workspace[current_workspace]
 *                 x += start
 */
      __pyx_t_10 = (__pyx_v_current_workspace + 1);
      if (unlikely(__pyx_v_nworkspaces == 0)) {
        PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_current_workspace = __Pyx_mod_long(__pyx_t_10, __pyx_v_nworkspaces);

      /* "GatEngine.pyx":935
 *                 x -= end
 *                 current_workspace = (current_workspace + 1) % nworkspaces
 *                 start, end = workspace[current_workspace]             # <<<<<<<<<<<<<<
 *                 x += start
 * 
 */
      __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_workspace), __pyx_v_current_workspace, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_7)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_1 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L13_unpacking_done;
        __pyx_L12_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_8 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L13_unpacking_done:;
      }
      __pyx_t_9 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_7); if (unlikely((__pyx_t_9 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_start = __pyx_t_9;
      __pyx_v_end = __pyx_t_5;

      /* "GatEngine.pyx":936
 *                 current_workspace = (current_workspace + 1) % nworkspaces
 *                 start, end = workspace[current_workspace]
 *                 x += start             # <<<<<<<<<<<<<<
 * 
 *             # sample a segment length from the histogram
 */
      __pyx_v_x = (__pyx_v_x + __pyx_v_start);
    }

    /* "GatEngine.pyx":939
 * 
 *             # sample a segment length from the histogram
 *             length = hs.sample()             # <<<<<<<<<<<<<<
 *             assert length > 0
 *             if self.current_orientation:
 */
    __pyx_v_length = ((struct __pyx_vtabstruct_9GatEngine_HistogramSampler *)__pyx_v_hs->__pyx_vtab)->sample(__pyx_v_hs, 0);

    /* "GatEngine.pyx":940
 *             # sample a segment length from the histogram
 *             length = hs.sample()
 *             assert length > 0             # <<<<<<<<<<<<<<
 *             if self.current_orientation:
 *                 sample._add( Segment( x, x + length ) )
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_length > 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "GatEngine.pyx":941
 *             length = hs.sample()
 *             assert length > 0
 *             if self.current_orientation:             # <<<<<<<<<<<<<<
 *                 sample._add( Segment( x, x + length ) )
 *                 self.current_orientation = 0
 */
    if (__pyx_v_self->current_orientation) {

      /* "GatEngine.pyx":942
 *             assert length > 0
 *             if self.current_orientation:
 *                 sample._add( Segment( x, x + length ) )             # <<<<<<<<<<<<<<
 *                 self.current_orientation = 0
 *             else:
 */
      __pyx_t_11.start = __pyx_v_x;
      __pyx_t_11.end = (__pyx_v_x + __pyx_v_length);
      __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_11); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":943
 *             if self.current_orientation:
 *                 sample._add( Segment( x, x + length ) )
 *                 self.current_orientation = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 sample._add( Segment( x-length, x) )
 */
      __pyx_v_self->current_orientation = 0;
      goto __pyx_L14;
    }
    /*else*/ {

      /* "GatEngine.pyx":945
 *                 self.current_orientation = 0
 *             else:
 *                 sample._add( Segment( x-length, x) )             # <<<<<<<<<<<<<<
 *                 self.current_orientation = 1
 *             x += increment
 */
      __pyx_t_11.start = (__pyx_v_x - __pyx_v_length);
      __pyx_t_11.end = __pyx_v_x;
      __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_11); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "GatEngine.pyx":946
 *             else:
 *                 sample._add( Segment( x-length, x) )
 *                 self.current_orientation = 1             # <<<<<<<<<<<<<<
 *             x += increment
 *             added += 1
 */
      __pyx_v_self->current_orientation = 1;
    }
    __pyx_L14:;

    /* "GatEngine.pyx":947
 *                 sample._add( Segment( x-length, x) )
 *                 self.current_orientation = 1
 *             x += increment             # <<<<<<<<<<<<<<
 *             added += 1
 * 
 */
    __pyx_v_x = (__pyx_v_x + __pyx_v_increment);

    /* "GatEngine.pyx":948
 *                 self.current_orientation = 1
 *             x += increment
 *             added += 1             # <<<<<<<<<<<<<<
 * 
 *         self.current_position = x
 */
    __pyx_v_added = (__pyx_v_added + 1);
  }

  /* "GatEngine.pyx":950
 *             added += 1
 * 
 *         self.current_position = x             # <<<<<<<<<<<<<<
 *         self.current_workspace = current_workspace
 * 
 */
  __pyx_v_self->current_position = __pyx_v_x;

  /* "GatEngine.pyx":951
 * 
 *         self.current_position = x
 *         self.current_workspace = current_workspace             # <<<<<<<<<<<<<<
 * 
 *         return sample
 */
  __pyx_v_self->current_workspace = __pyx_v_current_workspace;

  /* "GatEngine.pyx":953
 *         self.current_workspace = current_workspace
 * 
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * def buildSamplerUniform( *args ):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.SamplerUniform.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF(__pyx_v_histogram);
  __Pyx_XDECREF(__pyx_v_bucket_size);
  __Pyx_XDECREF((PyObject *)__pyx_v_hs);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_14SamplerUniform_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_14SamplerUniform_4sample[] = "SamplerUniform.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\nreturn a sampled list of segments.";
static PyObject *__pyx_pw_9GatEngine_14SamplerUniform_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerUniform.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_14SamplerUniform_4sample(((struct __pyx_obj_9GatEngine_SamplerUniform *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":891
 *                                       self.current_position) )
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_14SamplerUniform_4sample(struct __pyx_obj_9GatEngine_SamplerUniform *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerUniform *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerUniform.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_7buildSamplerUniform(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_6buildSamplerUniform[] = "buildSamplerUniform(*args)\nunpickling - return a rebuilt SamplerUniform object.";
static PyMethodDef __pyx_mdef_9GatEngine_7buildSamplerUniform = {__Pyx_NAMESTR("buildSamplerUniform"), (PyCFunction)__pyx_pw_9GatEngine_7buildSamplerUniform, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_6buildSamplerUniform)};
static PyObject *__pyx_pw_9GatEngine_7buildSamplerUniform(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildSamplerUniform (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildSamplerUniform", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_6buildSamplerUniform(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":955
 *         return sample
 * 
 * def buildSamplerUniform( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerUniform object.'''
 *     return SamplerUniform( *args )
 */

static PyObject *__pyx_pf_9GatEngine_6buildSamplerUniform(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildSamplerUniform", 0);

  /* "GatEngine.pyx":957
 * def buildSamplerUniform( *args ):
 *     '''unpickling - return a rebuilt SamplerUniform object.'''
 *     return SamplerUniform( *args )             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SamplerUniform)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildSamplerUniform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_12SamplerShift_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_12SamplerShift_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_radius = 0;
  PyObject *__pyx_v_extension = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__radius,&__pyx_n_s__extension,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_int_2);
    values[1] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__radius);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__extension);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_radius = values[0];
    __pyx_v_extension = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerShift.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_12SamplerShift___init__(((struct __pyx_obj_9GatEngine_SamplerShift *)__pyx_v_self), __pyx_v_radius, __pyx_v_extension);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":985
 *     cdef int extension
 * 
 *     def __init__( self,             # <<<<<<<<<<<<<<
 *                   radius = 2,
 *                   extension = 0):
 */

static int __pyx_pf_9GatEngine_12SamplerShift___init__(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self, PyObject *__pyx_v_radius, PyObject *__pyx_v_extension) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":989
 *                   extension = 0):
 * 
 *         self.radius = radius             # <<<<<<<<<<<<<<
 *         self.extension = extension
 * 
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_radius); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->radius = __pyx_t_1;

  /* "GatEngine.pyx":990
 * 
 *         self.radius = radius
 *         self.extension = extension             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_extension); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->extension = __pyx_t_2;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.SamplerShift.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12SamplerShift_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_12SamplerShift_2__reduce__[] = "SamplerShift.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_12SamplerShift_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_12SamplerShift_2__reduce__(((struct __pyx_obj_9GatEngine_SamplerShift *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":992
 *         self.extension = extension
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildSamplerShift, (self.radius,
 *                                     self.extension)),
 */

static PyObject *__pyx_pf_9GatEngine_12SamplerShift_2__reduce__(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":993
 * 
 *     def __reduce__(self):
 *         return (buildSamplerShift, (self.radius,             # <<<<<<<<<<<<<<
 *                                     self.extension)),
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__buildSamplerShift); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->radius); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "GatEngine.pyx":994
 *     def __reduce__(self):
 *         return (buildSamplerShift, (self.radius,
 *                                     self.extension)),             # <<<<<<<<<<<<<<
 * 
 *     cpdef SegmentList sample( self,
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->extension); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.SamplerShift.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":996
 *                                     self.extension)),
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_12SamplerShift_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_12SamplerShift_sample(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  struct __pyx_t_14GatSegmentList_Segment __pyx_v_segment;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = 0;
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  __pyx_t_14GatSegmentList_Position __pyx_v_x;
  __pyx_t_14GatSegmentList_Position __pyx_v_midpoint;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_start;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_ws_start;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_ws_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_shift_area;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_remainder;
  double __pyx_v_half_radius;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_half_extension;
  struct __pyx_t_14GatSegmentList_Segment *__pyx_v__working_segments;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_ws = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  struct __pyx_t_14GatSegmentList_Segment *__pyx_t_5;
  Py_ssize_t __pyx_t_6;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_7;
  __pyx_t_14GatSegmentList_Position __pyx_t_8;
  __pyx_t_14GatSegmentList_Position __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_12SamplerShift_5sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":1008
 *         '''
 * 
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         cdef Segment segment
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":1016
 *         cdef PositionDifference shift, start, end, ws_start, ws_end, shift_area
 *         cdef PositionDifference remainder, remainder_left, remainder_right
 *         cdef double half_radius = self.radius / 2             # <<<<<<<<<<<<<<
 *         cdef PositionDifference half_extension = self.extension // 2
 *         cdef Segment * _working_segments
 */
  __pyx_v_half_radius = (__pyx_v_self->radius / 2.0);

  /* "GatEngine.pyx":1017
 *         cdef PositionDifference remainder, remainder_left, remainder_right
 *         cdef double half_radius = self.radius / 2
 *         cdef PositionDifference half_extension = self.extension // 2             # <<<<<<<<<<<<<<
 *         cdef Segment * _working_segments
 *         cdef SegmentList ws
 */
  __pyx_v_half_extension = __Pyx_div_long(__pyx_v_self->extension, 2);

  /* "GatEngine.pyx":1022
 * 
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         working_segments.filter( workspace )
 *         _working_segments = working_segments.segments
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1023
 *         # collect all segments in workspace
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )             # <<<<<<<<<<<<<<
 *         _working_segments = working_segments.segments
 * 
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->filter(__pyx_v_working_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1024
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )
 *         _working_segments = working_segments.segments             # <<<<<<<<<<<<<<
 * 
 *         # allocate sample large enough
 */
  __pyx_t_5 = __pyx_v_working_segments->segments;
  __pyx_v__working_segments = __pyx_t_5;

  /* "GatEngine.pyx":1027
 * 
 *         # allocate sample large enough
 *         sample = SegmentList( len(working_segments) * 2 )             # <<<<<<<<<<<<<<
 * 
 *         if len(working_segments) == 0:
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_t_6 * 2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1029
 *         sample = SegmentList( len(working_segments) * 2 )
 * 
 *         if len(working_segments) == 0:             # <<<<<<<<<<<<<<
 *             return sample
 * 
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_6 == 0);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":1030
 * 
 *         if len(working_segments) == 0:
 *             return sample             # <<<<<<<<<<<<<<
 * 
 *         for x from 0 <= x < len(working_segments):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_sample));
    __pyx_r = __pyx_v_sample;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1032
 *             return sample
 * 
 *         for x from 0 <= x < len(working_segments):             # <<<<<<<<<<<<<<
 *             segment = _working_segments[x]
 *             length = segment.end - segment.start
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_6; __pyx_v_x++) {

    /* "GatEngine.pyx":1033
 * 
 *         for x from 0 <= x < len(working_segments):
 *             segment = _working_segments[x]             # <<<<<<<<<<<<<<
 *             length = segment.end - segment.start
 *             midpoint = segment.start + length // 2
 */
    __pyx_v_segment = (__pyx_v__working_segments[__pyx_v_x]);

    /* "GatEngine.pyx":1034
 *         for x from 0 <= x < len(working_segments):
 *             segment = _working_segments[x]
 *             length = segment.end - segment.start             # <<<<<<<<<<<<<<
 *             midpoint = segment.start + length // 2
 *             if self.extension:
 */
    __pyx_v_length = (__pyx_v_segment.end - __pyx_v_segment.start);

    /* "GatEngine.pyx":1035
 *             segment = _working_segments[x]
 *             length = segment.end - segment.start
 *             midpoint = segment.start + length // 2             # <<<<<<<<<<<<<<
 *             if self.extension:
 *                 shift_area = half_extension
 */
    __pyx_v_midpoint = (__pyx_v_segment.start + __Pyx_div_long(__pyx_v_length, 2));

    /* "GatEngine.pyx":1036
 *             length = segment.end - segment.start
 *             midpoint = segment.start + length // 2
 *             if self.extension:             # <<<<<<<<<<<<<<
 *                 shift_area = half_extension
 *             else:
 */
    if (__pyx_v_self->extension) {

      /* "GatEngine.pyx":1037
 *             midpoint = segment.start + length // 2
 *             if self.extension:
 *                 shift_area = half_extension             # <<<<<<<<<<<<<<
 *             else:
 *                 shift_area = <Position>floor(length * half_radius)
 */
      __pyx_v_shift_area = __pyx_v_half_extension;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "GatEngine.pyx":1039
 *                 shift_area = half_extension
 *             else:
 *                 shift_area = <Position>floor(length * half_radius)             # <<<<<<<<<<<<<<
 * 
 *             # get workspace around segment
 */
      __pyx_v_shift_area = ((__pyx_t_14GatSegmentList_Position)floor((__pyx_v_length * __pyx_v_half_radius)));
    }
    __pyx_L6:;

    /* "GatEngine.pyx":1042
 * 
 *             # get workspace around segment
 *             ws_start = lmax(0, midpoint - shift_area)             # <<<<<<<<<<<<<<
 *             ws_end = lmax(0, midpoint + shift_area)
 *             ws = workspace.getOverlappingSegmentsWithRange( ws_start, ws_end )
 */
    __pyx_v_ws_start = __pyx_f_9GatEngine_lmax(0, (__pyx_v_midpoint - __pyx_v_shift_area));

    /* "GatEngine.pyx":1043
 *             # get workspace around segment
 *             ws_start = lmax(0, midpoint - shift_area)
 *             ws_end = lmax(0, midpoint + shift_area)             # <<<<<<<<<<<<<<
 *             ws = workspace.getOverlappingSegmentsWithRange( ws_start, ws_end )
 *             ws.truncate( Segment( ws_start, ws_end ) )
 */
    __pyx_v_ws_end = __pyx_f_9GatEngine_lmax(0, (__pyx_v_midpoint + __pyx_v_shift_area));

    /* "GatEngine.pyx":1044
 *             ws_start = lmax(0, midpoint - shift_area)
 *             ws_end = lmax(0, midpoint + shift_area)
 *             ws = workspace.getOverlappingSegmentsWithRange( ws_start, ws_end )             # <<<<<<<<<<<<<<
 *             ws.truncate( Segment( ws_start, ws_end ) )
 * 
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_workspace->__pyx_vtab)->getOverlappingSegmentsWithRange(__pyx_v_workspace, __pyx_v_ws_start, __pyx_v_ws_end, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF(((PyObject *)__pyx_v_ws));
    __pyx_v_ws = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":1045
 *             ws_end = lmax(0, midpoint + shift_area)
 *             ws = workspace.getOverlappingSegmentsWithRange( ws_start, ws_end )
 *             ws.truncate( Segment( ws_start, ws_end ) )             # <<<<<<<<<<<<<<
 * 
 *             start = ws.getRandomPosition()
 */
    __pyx_t_7.start = __pyx_v_ws_start;
    __pyx_t_7.end = __pyx_v_ws_end;
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->truncate(__pyx_v_ws, __pyx_t_7)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "GatEngine.pyx":1047
 *             ws.truncate( Segment( ws_start, ws_end ) )
 * 
 *             start = ws.getRandomPosition()             # <<<<<<<<<<<<<<
 *             if numpy.random.randint( 0,2 ):
 *                 end = start + length
 */
    __pyx_v_start = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->getRandomPosition(__pyx_v_ws, 0);

    /* "GatEngine.pyx":1048
 * 
 *             start = ws.getRandomPosition()
 *             if numpy.random.randint( 0,2 ):             # <<<<<<<<<<<<<<
 *                 end = start + length
 *             else:
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__randint); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

      /* "GatEngine.pyx":1049
 *             start = ws.getRandomPosition()
 *             if numpy.random.randint( 0,2 ):
 *                 end = start + length             # <<<<<<<<<<<<<<
 *             else:
 *                 end = start
 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_length);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "GatEngine.pyx":1051
 *                 end = start + length
 *             else:
 *                 end = start             # <<<<<<<<<<<<<<
 *                 start = end - length
 * 
 */
      __pyx_v_end = __pyx_v_start;

      /* "GatEngine.pyx":1052
 *             else:
 *                 end = start
 *                 start = end - length             # <<<<<<<<<<<<<<
 * 
 *             # ws_start is now the intersection of workspace and sampling space
 */
      __pyx_v_start = (__pyx_v_end - __pyx_v_length);
    }
    __pyx_L7:;

    /* "GatEngine.pyx":1055
 * 
 *             # ws_start is now the intersection of workspace and sampling space
 *             ws_start, ws_end = ws.min(), ws.max()             # <<<<<<<<<<<<<<
 * 
 *             remainder = length
 */
    __pyx_t_8 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->min(__pyx_v_ws, 0);
    __pyx_t_9 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->max(__pyx_v_ws, 0);
    __pyx_v_ws_start = __pyx_t_8;
    __pyx_v_ws_end = __pyx_t_9;

    /* "GatEngine.pyx":1057
 *             ws_start, ws_end = ws.min(), ws.max()
 * 
 *             remainder = length             # <<<<<<<<<<<<<<
 *             if start < ws_start:
 *                 # start might be further than length outside of range
 */
    __pyx_v_remainder = __pyx_v_length;

    /* "GatEngine.pyx":1058
 * 
 *             remainder = length
 *             if start < ws_start:             # <<<<<<<<<<<<<<
 *                 # start might be further than length outside of range
 *                 remainder = lmin(ws_start - start, length)
 */
    __pyx_t_4 = (__pyx_v_start < __pyx_v_ws_start);
    if (__pyx_t_4) {

      /* "GatEngine.pyx":1060
 *             if start < ws_start:
 *                 # start might be further than length outside of range
 *                 remainder = lmin(ws_start - start, length)             # <<<<<<<<<<<<<<
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length - remainder ) )
 *                 sample.extend( ws.getFilledSegmentsFromEnd( ws_end, remainder ) )
 */
      __pyx_v_remainder = __pyx_f_9GatEngine_lmin((__pyx_v_ws_start - __pyx_v_start), __pyx_v_length);

      /* "GatEngine.pyx":1061
 *                 # start might be further than length outside of range
 *                 remainder = lmin(ws_start - start, length)
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length - remainder ) )             # <<<<<<<<<<<<<<
 *                 sample.extend( ws.getFilledSegmentsFromEnd( ws_end, remainder ) )
 *             elif end > ws_end:
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->getFilledSegmentsFromStart(__pyx_v_ws, __pyx_v_start, (__pyx_v_length - __pyx_v_remainder), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->extend(__pyx_v_sample, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1), 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "GatEngine.pyx":1062
 *                 remainder = lmin(ws_start - start, length)
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length - remainder ) )
 *                 sample.extend( ws.getFilledSegmentsFromEnd( ws_end, remainder ) )             # <<<<<<<<<<<<<<
 *             elif end > ws_end:
 *                 # end might be further than length outside of range
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->getFilledSegmentsFromEnd(__pyx_v_ws, __pyx_v_ws_end, __pyx_v_remainder, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->extend(__pyx_v_sample, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L8;
    }

    /* "GatEngine.pyx":1063
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length - remainder ) )
 *                 sample.extend( ws.getFilledSegmentsFromEnd( ws_end, remainder ) )
 *             elif end > ws_end:             # <<<<<<<<<<<<<<
 *                 # end might be further than length outside of range
 *                 remainder = lmin(end - ws_end, length)
 */
    __pyx_t_4 = (__pyx_v_end > __pyx_v_ws_end);
    if (__pyx_t_4) {

      /* "GatEngine.pyx":1065
 *             elif end > ws_end:
 *                 # end might be further than length outside of range
 *                 remainder = lmin(end - ws_end, length)             # <<<<<<<<<<<<<<
 *                 sample.extend( ws.getFilledSegmentsFromEnd( end, length - remainder ) )
 *                 sample.extend( ws.getFilledSegmentsFromStart( ws_start, remainder ) )
 */
      __pyx_v_remainder = __pyx_f_9GatEngine_lmin((__pyx_v_end - __pyx_v_ws_end), __pyx_v_length);

      /* "GatEngine.pyx":1066
 *                 # end might be further than length outside of range
 *                 remainder = lmin(end - ws_end, length)
 *                 sample.extend( ws.getFilledSegmentsFromEnd( end, length - remainder ) )             # <<<<<<<<<<<<<<
 *                 sample.extend( ws.getFilledSegmentsFromStart( ws_start, remainder ) )
 *             else:
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->getFilledSegmentsFromEnd(__pyx_v_ws, __pyx_v_end, (__pyx_v_length - __pyx_v_remainder), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->extend(__pyx_v_sample, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1), 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "GatEngine.pyx":1067
 *                 remainder = lmin(end - ws_end, length)
 *                 sample.extend( ws.getFilledSegmentsFromEnd( end, length - remainder ) )
 *                 sample.extend( ws.getFilledSegmentsFromStart( ws_start, remainder ) )             # <<<<<<<<<<<<<<
 *             else:
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length ) )
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->getFilledSegmentsFromStart(__pyx_v_ws, __pyx_v_ws_start, __pyx_v_remainder, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->extend(__pyx_v_sample, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "GatEngine.pyx":1069
 *                 sample.extend( ws.getFilledSegmentsFromStart( ws_start, remainder ) )
 *             else:
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length ) )             # <<<<<<<<<<<<<<
 * 
 *         sample.normalize()
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_ws->__pyx_vtab)->getFilledSegmentsFromStart(__pyx_v_ws, __pyx_v_start, __pyx_v_length, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->extend(__pyx_v_sample, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1), 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L8:;
  }

  /* "GatEngine.pyx":1071
 *                 sample.extend( ws.getFilledSegmentsFromStart( start, length ) )
 * 
 *         sample.normalize()             # <<<<<<<<<<<<<<
 *         return sample
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->normalize(__pyx_v_sample, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1072
 * 
 *         sample.normalize()
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * def buildSamplerShift( *args ):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.SamplerShift.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_ws);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12SamplerShift_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12SamplerShift_4sample[] = "SamplerShift.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\ncreate a random sample of segments.\n\n        *segments* - a list of segments\n        \n        *workspace* - the workspace to use\n\n        returns: a list of sampled segments.\n        ";
static PyObject *__pyx_pw_9GatEngine_12SamplerShift_5sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerShift.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_12SamplerShift_4sample(((struct __pyx_obj_9GatEngine_SamplerShift *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":996
 *                                     self.extension)),
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_12SamplerShift_4sample(struct __pyx_obj_9GatEngine_SamplerShift *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerShift *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerShift.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_9buildSamplerShift(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_8buildSamplerShift[] = "buildSamplerShift(*args)\nunpickling - return a rebuilt SamplerShift object.";
static PyMethodDef __pyx_mdef_9GatEngine_9buildSamplerShift = {__Pyx_NAMESTR("buildSamplerShift"), (PyCFunction)__pyx_pw_9GatEngine_9buildSamplerShift, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_8buildSamplerShift)};
static PyObject *__pyx_pw_9GatEngine_9buildSamplerShift(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildSamplerShift (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildSamplerShift", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_8buildSamplerShift(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1074
 *         return sample
 * 
 * def buildSamplerShift( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return SamplerShift( *args )
 */

static PyObject *__pyx_pf_9GatEngine_8buildSamplerShift(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildSamplerShift", 0);

  /* "GatEngine.pyx":1076
 * def buildSamplerShift( *args ):
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return SamplerShift( *args )             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_SamplerShift)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildSamplerShift", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_23SamplerLocalPermutation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_23SamplerLocalPermutation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_9GatEngine_23SamplerLocalPermutation___init__(((struct __pyx_obj_9GatEngine_SamplerLocalPermutation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1109
 *     '''
 * 
 *     def __init__( self ):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static int __pyx_pf_9GatEngine_23SamplerLocalPermutation___init__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerLocalPermutation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1112
 *         pass
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_23SamplerLocalPermutation_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_23SamplerLocalPermutation_sample(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerLocalPermutation *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = 0;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_work_start;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_work_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_start;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_last;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_total_length;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_free_length;
  CYTHON_UNUSED struct __pyx_t_14GatSegmentList_Segment *__pyx_v__working_segments;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_shift;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  PyObject *__pyx_v_lengths = NULL;
  PyObject *__pyx_v_points = NULL;
  PyObject *__pyx_v_x = NULL;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  __pyx_t_14GatSegmentList_PositionDifference __pyx_t_10;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_t_11;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  struct __pyx_t_14GatSegmentList_Segment *__pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_23SamplerLocalPermutation_3sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":1128
 *         '''
 * 
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         cdef Segment segment
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":1136
 *         cdef Segment* _working_segments
 *         cdef PositionDifference shift
 *         cdef SegmentList sample = SegmentList()             # <<<<<<<<<<<<<<
 * 
 *         for work_start, work_end in workspace:
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":1138
 *         cdef SegmentList sample = SegmentList()
 * 
 *         for work_start, work_end in workspace:             # <<<<<<<<<<<<<<
 * 
 *             # collect all segments in this workspace segment
 */
  if (PyList_CheckExact(((PyObject *)__pyx_v_workspace)) || PyTuple_CheckExact(((PyObject *)__pyx_v_workspace))) {
    __pyx_t_1 = ((PyObject *)__pyx_v_workspace); __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_workspace)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_work_start = __pyx_t_10;
    __pyx_v_work_end = __pyx_t_11;

    /* "GatEngine.pyx":1141
 * 
 *             # collect all segments in this workspace segment
 *             working_segments = segments.getOverlappingSegments( Segment( work_start, work_end) )             # <<<<<<<<<<<<<<
 *             if len(working_segments) == 0: continue
 *             _working_segments = working_segments.segments
 */
    __pyx_t_12.start = __pyx_v_work_start;
    __pyx_t_12.end = __pyx_v_work_end;
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segments->__pyx_vtab)->getOverlappingSegments(__pyx_v_segments, __pyx_t_12)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF(((PyObject *)__pyx_v_working_segments));
    __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":1142
 *             # collect all segments in this workspace segment
 *             working_segments = segments.getOverlappingSegments( Segment( work_start, work_end) )
 *             if len(working_segments) == 0: continue             # <<<<<<<<<<<<<<
 *             _working_segments = working_segments.segments
 * 
 */
    __pyx_t_13 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = (__pyx_t_13 == 0);
    if (__pyx_t_4) {
      goto __pyx_L3_continue;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "GatEngine.pyx":1143
 *             working_segments = segments.getOverlappingSegments( Segment( work_start, work_end) )
 *             if len(working_segments) == 0: continue
 *             _working_segments = working_segments.segments             # <<<<<<<<<<<<<<
 * 
 *             lengths = [ x[1] - x[0] for x in working_segments ]
 */
    __pyx_t_14 = __pyx_v_working_segments->segments;
    __pyx_v__working_segments = __pyx_t_14;

    /* "GatEngine.pyx":1145
 *             _working_segments = working_segments.segments
 * 
 *             lengths = [ x[1] - x[0] for x in working_segments ]             # <<<<<<<<<<<<<<
 *             total_length = sum( lengths )
 * 
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyList_CheckExact(((PyObject *)__pyx_v_working_segments)) || PyTuple_CheckExact(((PyObject *)__pyx_v_working_segments))) {
      __pyx_t_7 = ((PyObject *)__pyx_v_working_segments); __Pyx_INCREF(__pyx_t_7); __pyx_t_13 = 0;
      __pyx_t_15 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_7 = PyObject_GetIter(((PyObject *)__pyx_v_working_segments)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_15 = Py_TYPE(__pyx_t_7)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_7)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_7)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_2 = __pyx_t_15(__pyx_t_7);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_2;
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_x, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_x, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_16 = PyNumber_Subtract(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_16))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = ((PyObject *)__pyx_t_3);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_lengths));
    __pyx_v_lengths = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "GatEngine.pyx":1146
 * 
 *             lengths = [ x[1] - x[0] for x in working_segments ]
 *             total_length = sum( lengths )             # <<<<<<<<<<<<<<
 * 
 *             # modify workspace to deal with overhanging segments
 */
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_v_lengths));
    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_lengths));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_lengths));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_total_length = __pyx_t_11;

    /* "GatEngine.pyx":1150
 *             # modify workspace to deal with overhanging segments
 *             # extend workspace
 *             work_start = lmin( working_segments.min(), work_start )             # <<<<<<<<<<<<<<
 *             work_end = lmax( working_segments.max(), work_end )
 *             free_length = work_end - work_start - total_length
 */
    __pyx_v_work_start = __pyx_f_9GatEngine_lmin(((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->min(__pyx_v_working_segments, 0), __pyx_v_work_start);

    /* "GatEngine.pyx":1151
 *             # extend workspace
 *             work_start = lmin( working_segments.min(), work_start )
 *             work_end = lmax( working_segments.max(), work_end )             # <<<<<<<<<<<<<<
 *             free_length = work_end - work_start - total_length
 * 
 */
    __pyx_v_work_end = __pyx_f_9GatEngine_lmax(((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->max(__pyx_v_working_segments, 0), __pyx_v_work_end);

    /* "GatEngine.pyx":1152
 *             work_start = lmin( working_segments.min(), work_start )
 *             work_end = lmax( working_segments.max(), work_end )
 *             free_length = work_end - work_start - total_length             # <<<<<<<<<<<<<<
 * 
 *             # 1. permutate order of segments
 */
    __pyx_v_free_length = ((__pyx_v_work_end - __pyx_v_work_start) - __pyx_v_total_length);

    /* "GatEngine.pyx":1155
 * 
 *             # 1. permutate order of segments
 *             random.shuffle( lengths )             # <<<<<<<<<<<<<<
 * 
 *             # 2. determine size of space between samples
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__shuffle); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_lengths));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_lengths));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_lengths));
    __pyx_t_16 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

    /* "GatEngine.pyx":1160
 *             # sample points in free area. The distance
 *             # between the points is the space left.
 *             points = []             # <<<<<<<<<<<<<<
 *             for x in range(len(lengths) ):
 *                 points.append( random.randint( 0, free_length ) )
 */
    __pyx_t_16 = PyList_New(0); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_XDECREF(((PyObject *)__pyx_v_points));
    __pyx_v_points = __pyx_t_16;
    __pyx_t_16 = 0;

    /* "GatEngine.pyx":1161
 *             # between the points is the space left.
 *             points = []
 *             for x in range(len(lengths) ):             # <<<<<<<<<<<<<<
 *                 points.append( random.randint( 0, free_length ) )
 *             points.sort()
 */
    __pyx_t_13 = PyList_GET_SIZE(((PyObject *)__pyx_v_lengths)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_16 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_16);
    __pyx_t_16 = 0;
    __pyx_t_16 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (PyList_CheckExact(__pyx_t_16) || PyTuple_CheckExact(__pyx_t_16)) {
      __pyx_t_3 = __pyx_t_16; __Pyx_INCREF(__pyx_t_3); __pyx_t_13 = 0;
      __pyx_t_15 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_15 = Py_TYPE(__pyx_t_3)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    for (;;) {
      if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_3)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_16 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_16); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_16 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_3)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_16 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_16); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_16 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_16 = __pyx_t_15(__pyx_t_3);
        if (unlikely(!__pyx_t_16)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_16);
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_16;
      __pyx_t_16 = 0;

      /* "GatEngine.pyx":1162
 *             points = []
 *             for x in range(len(lengths) ):
 *                 points.append( random.randint( 0, free_length ) )             # <<<<<<<<<<<<<<
 *             points.sort()
 * 
 */
      __pyx_t_16 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_7 = PyObject_GetAttr(__pyx_t_16, __pyx_n_s__randint); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PyInt_FromLong(__pyx_v_free_length); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      __pyx_t_16 = 0;
      __pyx_t_16 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_t_17 = PyList_Append(__pyx_v_points, __pyx_t_16); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "GatEngine.pyx":1163
 *             for x in range(len(lengths) ):
 *                 points.append( random.randint( 0, free_length ) )
 *             points.sort()             # <<<<<<<<<<<<<<
 * 
 *             # cycle shift to avoid edge effects
 */
    __pyx_t_17 = PyList_Sort(((PyObject *)__pyx_v_points)); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "GatEngine.pyx":1166
 * 
 *             # cycle shift to avoid edge effects
 *             shift = random.randint( 0, free_length )             # <<<<<<<<<<<<<<
 * 
 *             # 3. move segments to appropriate place
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_16 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__randint); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromLong(__pyx_v_free_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_16, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_shift = __pyx_t_11;

    /* "GatEngine.pyx":1169
 * 
 *             # 3. move segments to appropriate place
 *             start = work_start + shift             # <<<<<<<<<<<<<<
 *             last = 0
 *             for x in range(len(lengths)):
 */
    __pyx_v_start = (__pyx_v_work_start + __pyx_v_shift);

    /* "GatEngine.pyx":1170
 *             # 3. move segments to appropriate place
 *             start = work_start + shift
 *             last = 0             # <<<<<<<<<<<<<<
 *             for x in range(len(lengths)):
 *                 start += points[x] - last
 */
    __pyx_v_last = 0;

    /* "GatEngine.pyx":1171
 *             start = work_start + shift
 *             last = 0
 *             for x in range(len(lengths)):             # <<<<<<<<<<<<<<
 *                 start += points[x] - last
 *                 # wrap around if beyond end of workspace
 */
    __pyx_t_13 = PyList_GET_SIZE(((PyObject *)__pyx_v_lengths)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_8 = __pyx_t_3; __Pyx_INCREF(__pyx_t_8); __pyx_t_13 = 0;
      __pyx_t_15 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_3); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_13); __Pyx_INCREF(__pyx_t_3); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_3 = __pyx_t_15(__pyx_t_8);
        if (unlikely(!__pyx_t_3)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":1172
 *             last = 0
 *             for x in range(len(lengths)):
 *                 start += points[x] - last             # <<<<<<<<<<<<<<
 *                 # wrap around if beyond end of workspace
 *                 if start > work_end:
 */
      __pyx_t_3 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_16 = PyObject_GetItem(((PyObject *)__pyx_v_points), __pyx_v_x); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_7 = PyInt_FromLong(__pyx_v_last); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyNumber_Subtract(__pyx_t_16, __pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_start = __pyx_t_11;

      /* "GatEngine.pyx":1174
 *                 start += points[x] - last
 *                 # wrap around if beyond end of workspace
 *                 if start > work_end:             # <<<<<<<<<<<<<<
 *                     start = work_start + start - work_end
 *                 end = start + lengths[x]
 */
      __pyx_t_4 = (__pyx_v_start > __pyx_v_work_end);
      if (__pyx_t_4) {

        /* "GatEngine.pyx":1175
 *                 # wrap around if beyond end of workspace
 *                 if start > work_end:
 *                     start = work_start + start - work_end             # <<<<<<<<<<<<<<
 *                 end = start + lengths[x]
 *                 if end < work_end:
 */
        __pyx_v_start = ((__pyx_v_work_start + __pyx_v_start) - __pyx_v_work_end);
        goto __pyx_L14;
      }
      __pyx_L14:;

      /* "GatEngine.pyx":1176
 *                 if start > work_end:
 *                     start = work_start + start - work_end
 *                 end = start + lengths[x]             # <<<<<<<<<<<<<<
 *                 if end < work_end:
 *                     sample._add( Segment(start, end ) )
 */
      __pyx_t_7 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_lengths), __pyx_v_x); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_end = __pyx_t_11;

      /* "GatEngine.pyx":1177
 *                     start = work_start + start - work_end
 *                 end = start + lengths[x]
 *                 if end < work_end:             # <<<<<<<<<<<<<<
 *                     sample._add( Segment(start, end ) )
 *                     start += lengths[x]
 */
      __pyx_t_4 = (__pyx_v_end < __pyx_v_work_end);
      if (__pyx_t_4) {

        /* "GatEngine.pyx":1178
 *                 end = start + lengths[x]
 *                 if end < work_end:
 *                     sample._add( Segment(start, end ) )             # <<<<<<<<<<<<<<
 *                     start += lengths[x]
 *                 else:
 */
        __pyx_t_12.start = __pyx_v_start;
        __pyx_t_12.end = __pyx_v_end;
        __pyx_t_3 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "GatEngine.pyx":1179
 *                 if end < work_end:
 *                     sample._add( Segment(start, end ) )
 *                     start += lengths[x]             # <<<<<<<<<<<<<<
 *                 else:
 *                     # wrap around segment
 */
        __pyx_t_3 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_lengths), __pyx_v_x); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_start = __pyx_t_11;
        goto __pyx_L15;
      }
      /*else*/ {

        /* "GatEngine.pyx":1182
 *                 else:
 *                     # wrap around segment
 *                     sample._add( Segment(start, work_end ) )             # <<<<<<<<<<<<<<
 *                     end = work_start + end - work_end
 *                     sample._add( Segment( work_start, end ) )
 */
        __pyx_t_12.start = __pyx_v_start;
        __pyx_t_12.end = __pyx_v_work_end;
        __pyx_t_7 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "GatEngine.pyx":1183
 *                     # wrap around segment
 *                     sample._add( Segment(start, work_end ) )
 *                     end = work_start + end - work_end             # <<<<<<<<<<<<<<
 *                     sample._add( Segment( work_start, end ) )
 * 
 */
        __pyx_v_end = ((__pyx_v_work_start + __pyx_v_end) - __pyx_v_work_end);

        /* "GatEngine.pyx":1184
 *                     sample._add( Segment(start, work_end ) )
 *                     end = work_start + end - work_end
 *                     sample._add( Segment( work_start, end ) )             # <<<<<<<<<<<<<<
 * 
 *                 start = end
 */
        __pyx_t_12.start = __pyx_v_work_start;
        __pyx_t_12.end = __pyx_v_end;
        __pyx_t_7 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __pyx_L15:;

      /* "GatEngine.pyx":1186
 *                     sample._add( Segment( work_start, end ) )
 * 
 *                 start = end             # <<<<<<<<<<<<<<
 *                 last = points[x]
 * 
 */
      __pyx_v_start = __pyx_v_end;

      /* "GatEngine.pyx":1187
 * 
 *                 start = end
 *                 last = points[x]             # <<<<<<<<<<<<<<
 * 
 *             assert start + (points[-1] - last) <= work_end, "start=%i, points[-1]=%i, work_end=%i" % \
 */
      __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_v_points), __pyx_v_x); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_last = __pyx_t_11;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "GatEngine.pyx":1189
 *                 last = points[x]
 * 
 *             assert start + (points[-1] - last) <= work_end, "start=%i, points[-1]=%i, work_end=%i" % \             # <<<<<<<<<<<<<<
 *                 (start, points[-1] -last, work_end)
 * 
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    __pyx_t_8 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_points), -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = PyInt_FromLong(__pyx_v_last); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromLong(__pyx_v_work_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_4)) {

      /* "GatEngine.pyx":1190
 * 
 *             assert start + (points[-1] - last) <= work_end, "start=%i, points[-1]=%i, work_end=%i" % \
 *                 (start, points[-1] -last, work_end)             # <<<<<<<<<<<<<<
 * 
 *             sample.normalize()
 */
      __pyx_t_8 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_points), -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyInt_FromLong(__pyx_v_last); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromLong(__pyx_v_work_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_8 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_2));
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "GatEngine.pyx":1192
 *                 (start, points[-1] -last, work_end)
 * 
 *             sample.normalize()             # <<<<<<<<<<<<<<
 *         return sample
 * 
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->normalize(__pyx_v_sample, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1193
 * 
 *             sample.normalize()
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("GatEngine.SamplerLocalPermutation.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XDECREF(__pyx_v_lengths);
  __Pyx_XDECREF(__pyx_v_points);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_23SamplerLocalPermutation_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_23SamplerLocalPermutation_2sample[] = "SamplerLocalPermutation.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\ncreate a random sample of segments.\n\n        .. note::\n            Still needs to optimized for speed.\n            The algorithm is not fully implemented yet.\n\n        *segments* - a list of segments\n        \n        *workspace* - the workspace to use\n\n        returns: a list of sampled segments.\n        ";
static PyObject *__pyx_pw_9GatEngine_23SamplerLocalPermutation_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerLocalPermutation.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_23SamplerLocalPermutation_2sample(((struct __pyx_obj_9GatEngine_SamplerLocalPermutation *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1112
 *         pass
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_23SamplerLocalPermutation_2sample(struct __pyx_obj_9GatEngine_SamplerLocalPermutation *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerLocalPermutation *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerLocalPermutation.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_24SamplerGlobalPermutation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_24SamplerGlobalPermutation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_9GatEngine_24SamplerGlobalPermutation___init__(((struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1225
 *     '''
 * 
 *     def __init__( self ):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static int __pyx_pf_9GatEngine_24SamplerGlobalPermutation___init__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1228
 *         pass
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_24SamplerGlobalPermutation_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_24SamplerGlobalPermutation_sample(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_working_workspace = 0;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_work_start;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_work_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_start;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_end;
  CYTHON_UNUSED __pyx_t_14GatSegmentList_PositionDifference __pyx_v_last_end;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_total_length;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_v_free_length;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  PyObject *__pyx_v_lengths = NULL;
  PyObject *__pyx_v_points = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_shift = NULL;
  PyObject *__pyx_v_count = NULL;
  PyObject *__pyx_v_idx = NULL;
  CYTHON_UNUSED __pyx_t_14GatSegmentList_Position __pyx_v_global_work_start;
  CYTHON_UNUSED __pyx_t_14GatSegmentList_Position __pyx_v_global_work_end;
  PyObject *__pyx_v_max_idx = NULL;
  PyObject *__pyx_v_last_ungapped_position = NULL;
  PyObject *__pyx_v_segment_idx = NULL;
  PyObject *__pyx_v_gap_length = NULL;
  PyObject *__pyx_v_increment = NULL;
  PyObject *__pyx_v_length = NULL;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __pyx_t_14GatSegmentList_PositionDifference __pyx_t_9;
  int __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  __pyx_t_14GatSegmentList_PositionDifference __pyx_t_12;
  __pyx_t_14GatSegmentList_Position __pyx_t_13;
  __pyx_t_14GatSegmentList_Position __pyx_t_14;
  struct __pyx_t_14GatSegmentList_Segment __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_24SamplerGlobalPermutation_3sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":1243
 *         '''
 * 
 *         assert workspace.isNormalized, "workspace is not normalized"             # <<<<<<<<<<<<<<
 * 
 *         cdef Segment segment
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_workspace), __pyx_n_s__isNormalized); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_12));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":1250
 *         cdef PositionDifference total_length, free_length
 * 
 *         cdef SegmentList sample = SegmentList()             # <<<<<<<<<<<<<<
 * 
 *         # collect all segments in workspace
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":1254
 *         # collect all segments in workspace
 *         # This method does not truncate.
 *         working_segments = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         working_segments.filter( workspace )
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_working_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1255
 *         # This method does not truncate.
 *         working_segments = SegmentList( clone = segments )
 *         working_segments.filter( workspace )             # <<<<<<<<<<<<<<
 * 
 *         if len(working_segments) == 0: return sample
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_segments->__pyx_vtab)->filter(__pyx_v_working_segments, __pyx_v_workspace, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1257
 *         working_segments.filter( workspace )
 * 
 *         if len(working_segments) == 0: return sample             # <<<<<<<<<<<<<<
 * 
 *         # create a copy of the workspace
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_working_segments)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_5 == 0);
  if (__pyx_t_4) {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_sample));
    __pyx_r = __pyx_v_sample;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1260
 * 
 *         # create a copy of the workspace
 *         working_workspace = SegmentList( clone = workspace )             # <<<<<<<<<<<<<<
 * 
 *         # extend workspace segments with segments
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_workspace)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_working_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":1263
 * 
 *         # extend workspace segments with segments
 *         working_workspace.extend( working_segments )             # <<<<<<<<<<<<<<
 *         working_workspace.merge( 0 )
 * 
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_workspace->__pyx_vtab)->extend(__pyx_v_working_workspace, __pyx_v_working_segments, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1264
 *         # extend workspace segments with segments
 *         working_workspace.extend( working_segments )
 *         working_workspace.merge( 0 )             # <<<<<<<<<<<<<<
 * 
 *         # get lengths of segments inside and extending from workspace
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_workspace->__pyx_vtab)->merge(__pyx_v_working_workspace, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1267
 * 
 *         # get lengths of segments inside and extending from workspace
 *         lengths = [ x[1] - x[0] for x in working_segments ]             # <<<<<<<<<<<<<<
 *         total_length = sum( lengths )
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyList_CheckExact(((PyObject *)__pyx_v_working_segments)) || PyTuple_CheckExact(((PyObject *)__pyx_v_working_segments))) {
    __pyx_t_3 = ((PyObject *)__pyx_v_working_segments); __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_working_segments)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_x, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_x, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__Pyx_PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((PyObject *)__pyx_t_1);
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_lengths = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1268
 *         # get lengths of segments inside and extending from workspace
 *         lengths = [ x[1] - x[0] for x in working_segments ]
 *         total_length = sum( lengths )             # <<<<<<<<<<<<<<
 * 
 *         # compute workspace size free of segments
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_lengths));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_lengths));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_lengths));
  __pyx_t_1 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_total_length = __pyx_t_9;

  /* "GatEngine.pyx":1271
 * 
 *         # compute workspace size free of segments
 *         free_length = working_workspace.sum()             # <<<<<<<<<<<<<<
 *         free_length -= total_length
 * 
 */
  __pyx_v_free_length = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_workspace->__pyx_vtab)->sum(__pyx_v_working_workspace, 0);

  /* "GatEngine.pyx":1272
 *         # compute workspace size free of segments
 *         free_length = working_workspace.sum()
 *         free_length -= total_length             # <<<<<<<<<<<<<<
 * 
 *         # 1. permutate order of segments
 */
  __pyx_v_free_length = (__pyx_v_free_length - __pyx_v_total_length);

  /* "GatEngine.pyx":1275
 * 
 *         # 1. permutate order of segments
 *         random.shuffle( lengths )             # <<<<<<<<<<<<<<
 * 
 *         # 2. determine size of space between samples
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__shuffle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_lengths));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_lengths));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_lengths));
  __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "GatEngine.pyx":1280
 *         # sample points in free area. The distance
 *         # between the points is the space left.
 *         points = []             # <<<<<<<<<<<<<<
 *         for x in range(len(lengths) ):
 *             points.append( random.randint( 0, free_length ) )
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_points = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "GatEngine.pyx":1281
 *         # between the points is the space left.
 *         points = []
 *         for x in range(len(lengths) ):             # <<<<<<<<<<<<<<
 *             points.append( random.randint( 0, free_length ) )
 *         points.sort()
 */
  __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_v_lengths)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_8) || PyTuple_CheckExact(__pyx_t_8)) {
    __pyx_t_1 = __pyx_t_8; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_8 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_8)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_8;
    __pyx_t_8 = 0;

    /* "GatEngine.pyx":1282
 *         points = []
 *         for x in range(len(lengths) ):
 *             points.append( random.randint( 0, free_length ) )             # <<<<<<<<<<<<<<
 *         points.sort()
 * 
 */
    __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__randint); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyInt_FromLong(__pyx_v_free_length); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __pyx_t_10 = PyList_Append(__pyx_v_points, __pyx_t_8); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1283
 *         for x in range(len(lengths) ):
 *             points.append( random.randint( 0, free_length ) )
 *         points.sort()             # <<<<<<<<<<<<<<
 * 
 *         # 3. cycle shift to avoid edge effects
 */
  __pyx_t_10 = PyList_Sort(((PyObject *)__pyx_v_points)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1286
 * 
 *         # 3. cycle shift to avoid edge effects
 *         shift = random.randint( 0, free_length )             # <<<<<<<<<<<<<<
 * 
 *         # find starting position
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__randint); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_free_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_v_shift = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":1289
 * 
 *         # find starting position
 *         count = 0             # <<<<<<<<<<<<<<
 *         idx = 0
 *         for start,end in working_workspace:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_count = __pyx_int_0;

  /* "GatEngine.pyx":1290
 *         # find starting position
 *         count = 0
 *         idx = 0             # <<<<<<<<<<<<<<
 *         for start,end in working_workspace:
 *             count += end - start
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_idx = __pyx_int_0;

  /* "GatEngine.pyx":1291
 *         count = 0
 *         idx = 0
 *         for start,end in working_workspace:             # <<<<<<<<<<<<<<
 *             count += end - start
 *             if count > shift:
 */
  if (PyList_CheckExact(((PyObject *)__pyx_v_working_workspace)) || PyTuple_CheckExact(((PyObject *)__pyx_v_working_workspace))) {
    __pyx_t_1 = ((PyObject *)__pyx_v_working_workspace); __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_working_workspace)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_7)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
      PyObject* sequence = __pyx_t_7;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_8)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 1; __pyx_t_3 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L11_unpacking_done;
      __pyx_L10_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L11_unpacking_done:;
    }
    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_start = __pyx_t_9;
    __pyx_v_end = __pyx_t_12;

    /* "GatEngine.pyx":1292
 *         idx = 0
 *         for start,end in working_workspace:
 *             count += end - start             # <<<<<<<<<<<<<<
 *             if count > shift:
 *                 count -= end - start
 */
    __pyx_t_7 = PyInt_FromLong((__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_count, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_v_count);
    __pyx_v_count = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":1293
 *         for start,end in working_workspace:
 *             count += end - start
 *             if count > shift:             # <<<<<<<<<<<<<<
 *                 count -= end - start
 *                 break
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_count, __pyx_v_shift, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {

      /* "GatEngine.pyx":1294
 *             count += end - start
 *             if count > shift:
 *                 count -= end - start             # <<<<<<<<<<<<<<
 *                 break
 *             idx += 1
 */
      __pyx_t_3 = PyInt_FromLong((__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyNumber_InPlaceSubtract(__pyx_v_count, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_count);
      __pyx_v_count = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "GatEngine.pyx":1295
 *             if count > shift:
 *                 count -= end - start
 *                 break             # <<<<<<<<<<<<<<
 *             idx += 1
 * 
 */
      goto __pyx_L9_break;
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "GatEngine.pyx":1296
 *                 count -= end - start
 *                 break
 *             idx += 1             # <<<<<<<<<<<<<<
 * 
 *         # idx is now the segment to start inserting in
 */
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_v_idx);
    __pyx_v_idx = __pyx_t_7;
    __pyx_t_7 = 0;
  }
  __pyx_L9_break:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1300
 *         # idx is now the segment to start inserting in
 *         # add missing residues
 *         start += shift - count             # <<<<<<<<<<<<<<
 * 
 *         # 4. move segments to appropriate place
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Subtract(__pyx_v_shift, __pyx_v_count); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_start = __pyx_t_12;

  /* "GatEngine.pyx":1303
 * 
 *         # 4. move segments to appropriate place
 *         last_end = 0             # <<<<<<<<<<<<<<
 *         global_work_start, global_work_end = working_workspace.min(), working_workspace.max()
 *         work_start, work_end = working_workspace[idx]
 */
  __pyx_v_last_end = 0;

  /* "GatEngine.pyx":1304
 *         # 4. move segments to appropriate place
 *         last_end = 0
 *         global_work_start, global_work_end = working_workspace.min(), working_workspace.max()             # <<<<<<<<<<<<<<
 *         work_start, work_end = working_workspace[idx]
 * 
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_workspace->__pyx_vtab)->min(__pyx_v_working_workspace, 0);
  __pyx_t_14 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_working_workspace->__pyx_vtab)->max(__pyx_v_working_workspace, 0);
  __pyx_v_global_work_start = __pyx_t_13;
  __pyx_v_global_work_end = __pyx_t_14;

  /* "GatEngine.pyx":1305
 *         last_end = 0
 *         global_work_start, global_work_end = working_workspace.min(), working_workspace.max()
 *         work_start, work_end = working_workspace[idx]             # <<<<<<<<<<<<<<
 * 
 *         #print "starting adding", start
 */
  __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_working_workspace), __pyx_v_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext;
    index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L13_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_7);
    index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L13_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L14_unpacking_done;
    __pyx_L13_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L14_unpacking_done:;
  }
  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_work_start = __pyx_t_12;
  __pyx_v_work_end = __pyx_t_9;

  /* "GatEngine.pyx":1308
 * 
 *         #print "starting adding", start
 *         max_idx = len(working_workspace)             # <<<<<<<<<<<<<<
 *         last_ungapped_position = 0
 *         for segment_idx in range( len(lengths) ):
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_working_workspace)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_max_idx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1309
 *         #print "starting adding", start
 *         max_idx = len(working_workspace)
 *         last_ungapped_position = 0             # <<<<<<<<<<<<<<
 *         for segment_idx in range( len(lengths) ):
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_last_ungapped_position = __pyx_int_0;

  /* "GatEngine.pyx":1310
 *         max_idx = len(working_workspace)
 *         last_ungapped_position = 0
 *         for segment_idx in range( len(lengths) ):             # <<<<<<<<<<<<<<
 * 
 *             # place a gap
 */
  __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_v_lengths)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF(__pyx_v_segment_idx);
    __pyx_v_segment_idx = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":1313
 * 
 *             # place a gap
 *             gap_length = points[segment_idx] - last_ungapped_position             # <<<<<<<<<<<<<<
 *             assert gap_length >= 0
 *             #print "gap_length", gap_length
 */
    __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_points), __pyx_v_segment_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_v_last_ungapped_position); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_v_gap_length);
    __pyx_v_gap_length = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "GatEngine.pyx":1314
 *             # place a gap
 *             gap_length = points[segment_idx] - last_ungapped_position
 *             assert gap_length >= 0             # <<<<<<<<<<<<<<
 *             #print "gap_length", gap_length
 *             # print "gap"
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_gap_length, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_4)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "GatEngine.pyx":1317
 *             #print "gap_length", gap_length
 *             # print "gap"
 *             while gap_length > 0:             # <<<<<<<<<<<<<<
 *                 increment = lmin( work_end - start, gap_length )
 *                 # print idx, start, start + increment, gap_length
 */
    while (1) {
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_gap_length, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!__pyx_t_4) break;

      /* "GatEngine.pyx":1318
 *             # print "gap"
 *             while gap_length > 0:
 *                 increment = lmin( work_end - start, gap_length )             # <<<<<<<<<<<<<<
 *                 # print idx, start, start + increment, gap_length
 *                 start += increment
 */
      __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_v_gap_length); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = PyInt_FromLong(__pyx_f_9GatEngine_lmin((__pyx_v_work_end - __pyx_v_start), __pyx_t_9)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_XDECREF(__pyx_v_increment);
      __pyx_v_increment = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "GatEngine.pyx":1320
 *                 increment = lmin( work_end - start, gap_length )
 *                 # print idx, start, start + increment, gap_length
 *                 start += increment             # <<<<<<<<<<<<<<
 *                 if start == work_end:
 *                     idx += 1
 */
      __pyx_t_7 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_v_increment); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_start = __pyx_t_9;

      /* "GatEngine.pyx":1321
 *                 # print idx, start, start + increment, gap_length
 *                 start += increment
 *                 if start == work_end:             # <<<<<<<<<<<<<<
 *                     idx += 1
 *                     if idx >= max_idx: idx = 0
 */
      __pyx_t_4 = (__pyx_v_start == __pyx_v_work_end);
      if (__pyx_t_4) {

        /* "GatEngine.pyx":1322
 *                 start += increment
 *                 if start == work_end:
 *                     idx += 1             # <<<<<<<<<<<<<<
 *                     if idx >= max_idx: idx = 0
 *                     work_start, work_end = working_workspace[idx]
 */
        __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_v_idx);
        __pyx_v_idx = __pyx_t_3;
        __pyx_t_3 = 0;

        /* "GatEngine.pyx":1323
 *                 if start == work_end:
 *                     idx += 1
 *                     if idx >= max_idx: idx = 0             # <<<<<<<<<<<<<<
 *                     work_start, work_end = working_workspace[idx]
 *                     start = work_start
 */
        __pyx_t_3 = PyObject_RichCompare(__pyx_v_idx, __pyx_v_max_idx, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_4) {
          __Pyx_INCREF(__pyx_int_0);
          __Pyx_DECREF(__pyx_v_idx);
          __pyx_v_idx = __pyx_int_0;
          goto __pyx_L20;
        }
        __pyx_L20:;

        /* "GatEngine.pyx":1324
 *                     idx += 1
 *                     if idx >= max_idx: idx = 0
 *                     work_start, work_end = working_workspace[idx]             # <<<<<<<<<<<<<<
 *                     start = work_start
 *                 gap_length -= increment
 */
        __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_working_workspace), __pyx_v_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
          PyObject* sequence = __pyx_t_3;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          #else
          __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        {
          Py_ssize_t index = -1;
          __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext;
          index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_7)) goto __pyx_L21_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_7);
          index = 1; __pyx_t_8 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_8)) goto __pyx_L21_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_8);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L22_unpacking_done;
          __pyx_L21_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L22_unpacking_done:;
        }
        __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_v_work_start = __pyx_t_9;
        __pyx_v_work_end = __pyx_t_12;

        /* "GatEngine.pyx":1325
 *                     if idx >= max_idx: idx = 0
 *                     work_start, work_end = working_workspace[idx]
 *                     start = work_start             # <<<<<<<<<<<<<<
 *                 gap_length -= increment
 *                 last_ungapped_position += increment
 */
        __pyx_v_start = __pyx_v_work_start;
        goto __pyx_L19;
      }
      __pyx_L19:;

      /* "GatEngine.pyx":1326
 *                     work_start, work_end = working_workspace[idx]
 *                     start = work_start
 *                 gap_length -= increment             # <<<<<<<<<<<<<<
 *                 last_ungapped_position += increment
 * 
 */
      __pyx_t_3 = PyNumber_InPlaceSubtract(__pyx_v_gap_length, __pyx_v_increment); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_gap_length);
      __pyx_v_gap_length = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":1327
 *                     start = work_start
 *                 gap_length -= increment
 *                 last_ungapped_position += increment             # <<<<<<<<<<<<<<
 * 
 *             # place a segment of a certain length
 */
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_last_ungapped_position, __pyx_v_increment); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_last_ungapped_position);
      __pyx_v_last_ungapped_position = __pyx_t_3;
      __pyx_t_3 = 0;
    }

    /* "GatEngine.pyx":1332
 *             # the segment is split into multiple components at
 *             # workspace gaps
 *             length = lengths[segment_idx]             # <<<<<<<<<<<<<<
 *             #print "segment", length
 * 
 */
    __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_lengths), __pyx_v_segment_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF(__pyx_v_length);
    __pyx_v_length = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":1335
 *             #print "segment", length
 * 
 *             while length > 0:             # <<<<<<<<<<<<<<
 *                 increment = lmin( work_end - start, length )
 *                 #print idx, 'start=',start, 'end=', start + increment, 'len=',length
 */
    while (1) {
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_length, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!__pyx_t_4) break;

      /* "GatEngine.pyx":1336
 * 
 *             while length > 0:
 *                 increment = lmin( work_end - start, length )             # <<<<<<<<<<<<<<
 *                 #print idx, 'start=',start, 'end=', start + increment, 'len=',length
 *                 if increment > 0:
 */
      __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_v_length); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PyInt_FromLong(__pyx_f_9GatEngine_lmin((__pyx_v_work_end - __pyx_v_start), __pyx_t_12)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_v_increment);
      __pyx_v_increment = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":1338
 *                 increment = lmin( work_end - start, length )
 *                 #print idx, 'start=',start, 'end=', start + increment, 'len=',length
 *                 if increment > 0:             # <<<<<<<<<<<<<<
 *                     sample._add( Segment( start, start + increment ) )
 *                 start += increment
 */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_increment, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_4) {

        /* "GatEngine.pyx":1339
 *                 #print idx, 'start=',start, 'end=', start + increment, 'len=',length
 *                 if increment > 0:
 *                     sample._add( Segment( start, start + increment ) )             # <<<<<<<<<<<<<<
 *                 start += increment
 *                 if start == work_end:
 */
        __pyx_t_15.start = __pyx_v_start;
        __pyx_t_3 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_v_increment); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_14 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_8); if (unlikely((__pyx_t_14 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_15.end = __pyx_t_14;
        __pyx_t_8 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->_add(__pyx_v_sample, __pyx_t_15); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L25;
      }
      __pyx_L25:;

      /* "GatEngine.pyx":1340
 *                 if increment > 0:
 *                     sample._add( Segment( start, start + increment ) )
 *                 start += increment             # <<<<<<<<<<<<<<
 *                 if start == work_end:
 *                     idx += 1
 */
      __pyx_t_8 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_v_increment); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_start = __pyx_t_12;

      /* "GatEngine.pyx":1341
 *                     sample._add( Segment( start, start + increment ) )
 *                 start += increment
 *                 if start == work_end:             # <<<<<<<<<<<<<<
 *                     idx += 1
 *                     if idx >= max_idx: idx = 0
 */
      __pyx_t_4 = (__pyx_v_start == __pyx_v_work_end);
      if (__pyx_t_4) {

        /* "GatEngine.pyx":1342
 *                 start += increment
 *                 if start == work_end:
 *                     idx += 1             # <<<<<<<<<<<<<<
 *                     if idx >= max_idx: idx = 0
 *                     work_start, work_end = working_workspace[idx]
 */
        __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_v_idx);
        __pyx_v_idx = __pyx_t_3;
        __pyx_t_3 = 0;

        /* "GatEngine.pyx":1343
 *                 if start == work_end:
 *                     idx += 1
 *                     if idx >= max_idx: idx = 0             # <<<<<<<<<<<<<<
 *                     work_start, work_end = working_workspace[idx]
 *                     start = work_start
 */
        __pyx_t_3 = PyObject_RichCompare(__pyx_v_idx, __pyx_v_max_idx, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_4) {
          __Pyx_INCREF(__pyx_int_0);
          __Pyx_DECREF(__pyx_v_idx);
          __pyx_v_idx = __pyx_int_0;
          goto __pyx_L27;
        }
        __pyx_L27:;

        /* "GatEngine.pyx":1344
 *                     idx += 1
 *                     if idx >= max_idx: idx = 0
 *                     work_start, work_end = working_workspace[idx]             # <<<<<<<<<<<<<<
 *                     start = work_start
 *                 length -= increment
 */
        __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_working_workspace), __pyx_v_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
          PyObject* sequence = __pyx_t_3;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          #else
          __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        {
          Py_ssize_t index = -1;
          __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext;
          index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_8)) goto __pyx_L28_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_8);
          index = 1; __pyx_t_7 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_7)) goto __pyx_L28_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L29_unpacking_done;
          __pyx_L28_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L29_unpacking_done:;
        }
        __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_work_start = __pyx_t_12;
        __pyx_v_work_end = __pyx_t_9;

        /* "GatEngine.pyx":1345
 *                     if idx >= max_idx: idx = 0
 *                     work_start, work_end = working_workspace[idx]
 *                     start = work_start             # <<<<<<<<<<<<<<
 *                 length -= increment
 * 
 */
        __pyx_v_start = __pyx_v_work_start;
        goto __pyx_L26;
      }
      __pyx_L26:;

      /* "GatEngine.pyx":1346
 *                     work_start, work_end = working_workspace[idx]
 *                     start = work_start
 *                 length -= increment             # <<<<<<<<<<<<<<
 * 
 *         sample.normalize()
 */
      __pyx_t_3 = PyNumber_InPlaceSubtract(__pyx_v_length, __pyx_v_increment); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_length);
      __pyx_v_length = __pyx_t_3;
      __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1348
 *                 length -= increment
 * 
 *         sample.normalize()             # <<<<<<<<<<<<<<
 * 
 *         return sample
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_sample->__pyx_vtab)->normalize(__pyx_v_sample, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":1350
 *         sample.normalize()
 * 
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * ########################################################
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.SamplerGlobalPermutation.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_working_segments);
  __Pyx_XDECREF((PyObject *)__pyx_v_working_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XDECREF(__pyx_v_lengths);
  __Pyx_XDECREF(__pyx_v_points);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_shift);
  __Pyx_XDECREF(__pyx_v_count);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_max_idx);
  __Pyx_XDECREF(__pyx_v_last_ungapped_position);
  __Pyx_XDECREF(__pyx_v_segment_idx);
  __Pyx_XDECREF(__pyx_v_gap_length);
  __Pyx_XDECREF(__pyx_v_increment);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_24SamplerGlobalPermutation_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_24SamplerGlobalPermutation_2sample[] = "SamplerGlobalPermutation.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\ncreate a random sample of segments.\n\n        .. note::\n            Still needs to optimized for speed\n\n        *segments* - a list of segments\n        \n        *workspace* - the workspace to use\n\n        returns: a list of sampled segments.\n        ";
static PyObject *__pyx_pw_9GatEngine_24SamplerGlobalPermutation_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerGlobalPermutation.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_24SamplerGlobalPermutation_2sample(((struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1228
 *         pass
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                                            SegmentList segments,
 *                                            SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_24SamplerGlobalPermutation_2sample(struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerGlobalPermutation *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerGlobalPermutation.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_12SamplerDummy_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12SamplerDummy___init__[] = "\n        returns a copy of the observed data.\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_12SamplerDummy___init__;
#endif
static int __pyx_pw_9GatEngine_12SamplerDummy_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_9GatEngine_12SamplerDummy___init__(((struct __pyx_obj_9GatEngine_SamplerDummy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1357
 * cdef class SamplerDummy(Sampler):
 * 
 *     def __init__( self ):             # <<<<<<<<<<<<<<
 *         '''
 *         returns a copy of the observed data.
 */

static int __pyx_pf_9GatEngine_12SamplerDummy___init__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerDummy *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1362
 *         '''
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                               SegmentList segments,
 *                               SegmentList workspace ):
 */

static PyObject *__pyx_pw_9GatEngine_12SamplerDummy_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_f_9GatEngine_12SamplerDummy_sample(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplerDummy *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, CYTHON_UNUSED struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace, int __pyx_skip_dispatch) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_sample = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sample); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_9GatEngine_12SamplerDummy_3sample)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_segments));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_segments));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_segments));
      __Pyx_INCREF(((PyObject *)__pyx_v_workspace));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_workspace));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_workspace));
      __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 = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "GatEngine.pyx":1368
 * 
 *         cdef SegmentList sample
 *         sample = SegmentList( clone = segments )             # <<<<<<<<<<<<<<
 *         return sample
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), ((PyObject *)__pyx_v_segments)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_sample = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1369
 *         cdef SegmentList sample
 *         sample = SegmentList( clone = segments )
 *         return sample             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_sample));
  __pyx_r = __pyx_v_sample;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.SamplerDummy.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sample);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12SamplerDummy_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12SamplerDummy_2sample[] = "SamplerDummy.sample(self, SegmentList segments, SegmentList workspace) -> SegmentList\nreturn a sampled list of segments.";
static PyObject *__pyx_pw_9GatEngine_12SamplerDummy_3sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__workspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sample", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplerDummy.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_12SamplerDummy_2sample(((struct __pyx_obj_9GatEngine_SamplerDummy *)__pyx_v_self), __pyx_v_segments, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1362
 *         '''
 * 
 *     cpdef SegmentList sample( self,             # <<<<<<<<<<<<<<
 *                               SegmentList segments,
 *                               SegmentList workspace ):
 */

static PyObject *__pyx_pf_9GatEngine_12SamplerDummy_2sample(struct __pyx_obj_9GatEngine_SamplerDummy *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_9GatEngine_SamplerDummy *)__pyx_v_self->__pyx_vtab)->sample(__pyx_v_self, __pyx_v_segments, __pyx_v_workspace, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplerDummy.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_24CounterNucleotideOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_24CounterNucleotideOverlap___call__[] = "return number of nucleotides overlapping between segments and annotations.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_24CounterNucleotideOverlap___call__;
#endif
static PyObject *__pyx_pw_9GatEngine_24CounterNucleotideOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_annotations = 0;
  CYTHON_UNUSED struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[3] = {0,0,0};

    /* "GatEngine.pyx":1384
 *     name = "nucleotide-overlap"
 * 
 *     def __call__(self, SegmentList segments, SegmentList annotations, SegmentList workspace = None ):             # <<<<<<<<<<<<<<
 *         '''return number of nucleotides overlapping between segments and annotations.'''
 *         return annotations.overlapWithSegments( segments )
 */
    values[2] = (PyObject *)((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_annotations = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.CounterNucleotideOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_annotations), __pyx_ptype_14GatSegmentList_SegmentList, 1, "annotations", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_24CounterNucleotideOverlap___call__(((struct __pyx_obj_9GatEngine_CounterNucleotideOverlap *)__pyx_v_self), __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_24CounterNucleotideOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterNucleotideOverlap *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_annotations, CYTHON_UNUSED struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":1386
 *     def __call__(self, SegmentList segments, SegmentList annotations, SegmentList workspace = None ):
 *         '''return number of nucleotides overlapping between segments and annotations.'''
 *         return annotations.overlapWithSegments( segments )             # <<<<<<<<<<<<<<
 * 
 * cdef class CounterNucleotideDensity(Counter):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_annotations->__pyx_vtab)->overlapWithSegments(__pyx_v_annotations, __pyx_v_segments, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.CounterNucleotideOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_24CounterNucleotideDensity_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_24CounterNucleotideDensity___call__[] = "return number of nucleotides overlapping between segments and annotations.\n        divided by the size of the workspace\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_24CounterNucleotideDensity___call__;
#endif
static PyObject *__pyx_pw_9GatEngine_24CounterNucleotideDensity_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_annotations = 0;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_segments = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[0]);
    __pyx_v_annotations = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[1]);
    __pyx_v_workspace = ((struct __pyx_obj_14GatSegmentList_SegmentList *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.CounterNucleotideDensity.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segments), __pyx_ptype_14GatSegmentList_SegmentList, 1, "segments", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_annotations), __pyx_ptype_14GatSegmentList_SegmentList, 1, "annotations", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_workspace), __pyx_ptype_14GatSegmentList_SegmentList, 1, "workspace", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_24CounterNucleotideDensity___call__(((struct __pyx_obj_9GatEngine_CounterNucleotideDensity *)__pyx_v_self), __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1391
 *     name = "nucleotide-density"
 * 
 *     def __call__(self, SegmentList segments, SegmentList annotations, SegmentList workspace ):             # <<<<<<<<<<<<<<
 *         '''return number of nucleotides overlapping between segments and annotations.
 *         divided by the size of the workspace
 */

static PyObject *__pyx_pf_9GatEngine_24CounterNucleotideDensity___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterNucleotideDensity *__pyx_v_self, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segments, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_annotations, struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_workspace) {
  __pyx_t_14GatSegmentList_Position __pyx_v_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":1396
 *         '''
 *         cdef Position l
 *         l = len(workspace)             # <<<<<<<<<<<<<<
 *         if l == 0: return 0
 *         return float(annotations.overlapWithSegments( segments )) / l
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_workspace)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_1;

  /* "GatEngine.pyx":1397
 *         cdef Position l
 *         l = len(workspace)
 *         if l == 0: return 0             # <<<<<<<<<<<<<<
 *         return float(annotations.overlapWithSegments( segments )) / l
 * 
 */
  __pyx_t_2 = (__pyx_v_l == 0);
  if (__pyx_t_2) {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1398
 *         l = len(workspace)
 *         if l == 0: return 0
 *         return float(annotations.overlapWithSegments( segments )) / l             # <<<<<<<<<<<<<<
 * 
 * cdef class CounterSegmentOverlap(Counter):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_l == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyFloat_FromDouble((((double)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_annotations->__pyx_vtab)->overlapWithSegments(__pyx_v_annotations, __pyx_v_segments, 0)) / __pyx_v_l)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.CounterNucleotideDensity.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_21CounterSegmentOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_21CounterSegmentOverlap___call__[] = "return number of segments overlapping with annotations.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_21CounterSegmentOverlap___call__;
#endif
static PyObject *__pyx_pw_9GatEngine_21CounterSegmentOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  CYTHON_UNUSED PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[3] = {0,0,0};

    /* "GatEngine.pyx":1403
 *     name = "segment-overlap"
 * 
 *     def __call__(self, segments, annotations, workspace = None ):             # <<<<<<<<<<<<<<
 *         '''return number of segments overlapping with annotations.'''
 *         return segments.intersectionWithSegments( annotations )
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_segments = values[0];
    __pyx_v_annotations = values[1];
    __pyx_v_workspace = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.CounterSegmentOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_21CounterSegmentOverlap___call__(((struct __pyx_obj_9GatEngine_CounterSegmentOverlap *)__pyx_v_self), __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_21CounterSegmentOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterSegmentOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":1405
 *     def __call__(self, segments, annotations, workspace = None ):
 *         '''return number of segments overlapping with annotations.'''
 *         return segments.intersectionWithSegments( annotations )             # <<<<<<<<<<<<<<
 * 
 * cdef class CounterSegmentMidpointOverlap(Counter):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_segments, __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __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 = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.CounterSegmentOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_29CounterSegmentMidpointOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_29CounterSegmentMidpointOverlap___call__[] = "return number of segments overlapping with annotations.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_29CounterSegmentMidpointOverlap___call__;
#endif
static PyObject *__pyx_pw_9GatEngine_29CounterSegmentMidpointOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  CYTHON_UNUSED PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[3] = {0,0,0};

    /* "GatEngine.pyx":1410
 *     name = "segment-midoverlap"
 * 
 *     def __call__(self, segments, annotations, workspace = None ):             # <<<<<<<<<<<<<<
 *         '''return number of segments overlapping with annotations.'''
 *         return segments.intersectionWithSegments( annotations, mode = "midpoint" )
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_segments = values[0];
    __pyx_v_annotations = values[1];
    __pyx_v_workspace = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.CounterSegmentMidpointOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_29CounterSegmentMidpointOverlap___call__(((struct __pyx_obj_9GatEngine_CounterSegmentMidpointOverlap *)__pyx_v_self), __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_29CounterSegmentMidpointOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterSegmentMidpointOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":1412
 *     def __call__(self, segments, annotations, workspace = None ):
 *         '''return number of segments overlapping with annotations.'''
 *         return segments.intersectionWithSegments( annotations, mode = "midpoint" )             # <<<<<<<<<<<<<<
 * 
 * cdef class CounterAnnotationOverlap(Counter):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_segments, __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__mode), ((PyObject *)__pyx_n_s__midpoint)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.CounterSegmentMidpointOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_24CounterAnnotationOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_24CounterAnnotationOverlap___call__[] = "return number of segments overlapping with annotations.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_24CounterAnnotationOverlap___call__;
#endif
static PyObject *__pyx_pw_9GatEngine_24CounterAnnotationOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  CYTHON_UNUSED PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[3] = {0,0,0};

    /* "GatEngine.pyx":1417
 *     name = "annotation-overlap"
 * 
 *     def __call__(self, segments, annotations, workspace = None ):             # <<<<<<<<<<<<<<
 *         '''return number of segments overlapping with annotations.'''
 *         return annotations.intersectionWithSegments( segments )
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_segments = values[0];
    __pyx_v_annotations = values[1];
    __pyx_v_workspace = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.CounterAnnotationOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_24CounterAnnotationOverlap___call__(((struct __pyx_obj_9GatEngine_CounterAnnotationOverlap *)__pyx_v_self), __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_24CounterAnnotationOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterAnnotationOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":1419
 *     def __call__(self, segments, annotations, workspace = None ):
 *         '''return number of segments overlapping with annotations.'''
 *         return annotations.intersectionWithSegments( segments )             # <<<<<<<<<<<<<<
 * 
 * cdef class CounterAnnotationMidpointOverlap(Counter):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_annotations, __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __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 = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.CounterAnnotationOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_32CounterAnnotationMidpointOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_32CounterAnnotationMidpointOverlap___call__[] = "return number of segments overlapping with annotations.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_32CounterAnnotationMidpointOverlap___call__;
#endif
static PyObject *__pyx_pw_9GatEngine_32CounterAnnotationMidpointOverlap_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  CYTHON_UNUSED PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[3] = {0,0,0};

    /* "GatEngine.pyx":1424
 *     name = "annotation-midoverlap"
 * 
 *     def __call__(self, segments, annotations, workspace = None ):             # <<<<<<<<<<<<<<
 *         '''return number of segments overlapping with annotations.'''
 *         return annotations.intersectionWithSegments( segments, mode = "midpoint" )
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_segments = values[0];
    __pyx_v_annotations = values[1];
    __pyx_v_workspace = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.CounterAnnotationMidpointOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_32CounterAnnotationMidpointOverlap___call__(((struct __pyx_obj_9GatEngine_CounterAnnotationMidpointOverlap *)__pyx_v_self), __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_32CounterAnnotationMidpointOverlap___call__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_CounterAnnotationMidpointOverlap *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, CYTHON_UNUSED PyObject *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":1426
 *     def __call__(self, segments, annotations, workspace = None ):
 *         '''return number of segments overlapping with annotations.'''
 *         return annotations.intersectionWithSegments( segments, mode = "midpoint" )             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_annotations, __pyx_n_s_20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__mode), ((PyObject *)__pyx_n_s__midpoint)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.CounterAnnotationMidpointOverlap.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1434
 * ############################################################
 * @cython.boundscheck(False)
 * cpdef getNPTwoSidedPValue( ar, val ):             # <<<<<<<<<<<<<<
 *     '''return pvalue for *val* within sorted array *ar*
 *     '''
 */

static PyObject *__pyx_pw_9GatEngine_11getNPTwoSidedPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9GatEngine_getNPTwoSidedPValue(PyObject *__pyx_v_ar, PyObject *__pyx_v_val, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_l = NULL;
  PyObject *__pyx_v_min_pval = NULL;
  PyObject *__pyx_v_pval = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  double __pyx_t_8;
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNPTwoSidedPValue", 0);

  /* "GatEngine.pyx":1437
 *     '''return pvalue for *val* within sorted array *ar*
 *     '''
 *     idx = numpy.searchsorted( ar, val )             # <<<<<<<<<<<<<<
 *     l = len(ar)
 *     min_pval = 1.0 / l
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__searchsorted); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_ar);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ar);
  __Pyx_GIVEREF(__pyx_v_ar);
  __Pyx_INCREF(__pyx_v_val);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_val);
  __Pyx_GIVEREF(__pyx_v_val);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_idx = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1438
 *     '''
 *     idx = numpy.searchsorted( ar, val )
 *     l = len(ar)             # <<<<<<<<<<<<<<
 *     min_pval = 1.0 / l
 *     if idx == l:
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_ar); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_l = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1439
 *     idx = numpy.searchsorted( ar, val )
 *     l = len(ar)
 *     min_pval = 1.0 / l             # <<<<<<<<<<<<<<
 *     if idx == l:
 *         pval = min_pval
 */
  __pyx_t_3 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_min_pval = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":1440
 *     l = len(ar)
 *     min_pval = 1.0 / l
 *     if idx == l:             # <<<<<<<<<<<<<<
 *         pval = min_pval
 *     elif idx > l / 2:
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_idx, __pyx_v_l, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "GatEngine.pyx":1441
 *     min_pval = 1.0 / l
 *     if idx == l:
 *         pval = min_pval             # <<<<<<<<<<<<<<
 *     elif idx > l / 2:
 *         # over-representation
 */
    __Pyx_INCREF(__pyx_v_min_pval);
    __pyx_v_pval = __pyx_v_min_pval;
    goto __pyx_L3;
  }

  /* "GatEngine.pyx":1442
 *     if idx == l:
 *         pval = min_pval
 *     elif idx > l / 2:             # <<<<<<<<<<<<<<
 *         # over-representation
 *         while idx > 0 and ar[idx] == val: idx -= 1
 */
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_v_l, __pyx_int_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_idx, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "GatEngine.pyx":1444
 *     elif idx > l / 2:
 *         # over-representation
 *         while idx > 0 and ar[idx] == val: idx -= 1             # <<<<<<<<<<<<<<
 *         pval = 1.0 - float(idx) / l
 *     else:
 */
    while (1) {
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_idx, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_5) {
        __pyx_t_3 = PyObject_GetItem(__pyx_v_ar, __pyx_v_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_v_val, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_5;
      }
      if (!__pyx_t_7) break;
      __pyx_t_1 = PyNumber_InPlaceSubtract(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_idx);
      __pyx_v_idx = __pyx_t_1;
      __pyx_t_1 = 0;
    }

    /* "GatEngine.pyx":1445
 *         # over-representation
 *         while idx > 0 and ar[idx] == val: idx -= 1
 *         pval = 1.0 - float(idx) / l             # <<<<<<<<<<<<<<
 *     else:
 *         # under-representation
 */
    __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_AsDouble(__pyx_v_idx); if (unlikely(__pyx_t_8 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_pval = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1448
 *     else:
 *         # under-representation
 *         while idx < l and ar[idx] == val: idx += 1             # <<<<<<<<<<<<<<
 *         pval = float(idx) / l
 * 
 */
    while (1) {
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_idx, __pyx_v_l, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        __pyx_t_3 = PyObject_GetItem(__pyx_v_ar, __pyx_v_idx); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_val, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_6 = __pyx_t_5;
      } else {
        __pyx_t_6 = __pyx_t_7;
      }
      if (!__pyx_t_6) break;
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_idx);
      __pyx_v_idx = __pyx_t_2;
      __pyx_t_2 = 0;
    }

    /* "GatEngine.pyx":1449
 *         # under-representation
 *         while idx < l and ar[idx] == val: idx += 1
 *         pval = float(idx) / l             # <<<<<<<<<<<<<<
 * 
 *     return dmax( min_pval, pval)
 */
    __pyx_t_8 = __Pyx_PyObject_AsDouble(__pyx_v_idx); if (unlikely(__pyx_t_8 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_v_l); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_pval = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1451
 *         pval = float(idx) / l
 * 
 *     return dmax( min_pval, pval)             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_min_pval); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_pval); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyFloat_FromDouble(__pyx_f_9GatEngine_dmax(__pyx_t_8, __pyx_t_9)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.getNPTwoSidedPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XDECREF(__pyx_v_min_pval);
  __Pyx_XDECREF(__pyx_v_pval);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_11getNPTwoSidedPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_10getNPTwoSidedPValue[] = "getNPTwoSidedPValue(ar, val)\nreturn pvalue for *val* within sorted array *ar*\n    ";
static PyObject *__pyx_pw_9GatEngine_11getNPTwoSidedPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ar = 0;
  PyObject *__pyx_v_val = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getNPTwoSidedPValue (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ar,&__pyx_n_s__val,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ar)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__val)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getNPTwoSidedPValue", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getNPTwoSidedPValue") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_ar = values[0];
    __pyx_v_val = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getNPTwoSidedPValue", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.getNPTwoSidedPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_10getNPTwoSidedPValue(__pyx_self, __pyx_v_ar, __pyx_v_val);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1434
 * ############################################################
 * @cython.boundscheck(False)
 * cpdef getNPTwoSidedPValue( ar, val ):             # <<<<<<<<<<<<<<
 *     '''return pvalue for *val* within sorted array *ar*
 *     '''
 */

static PyObject *__pyx_pf_9GatEngine_10getNPTwoSidedPValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ar, PyObject *__pyx_v_val) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNPTwoSidedPValue", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9GatEngine_getNPTwoSidedPValue(__pyx_v_ar, __pyx_v_val, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.getNPTwoSidedPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_13getNPTwoSidedPValueFast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12getNPTwoSidedPValueFast[] = "getNPTwoSidedPValueFast(ndarray ar, double val, double mean)\nreturn a two-sided pvalue.\n\n    Fast if val is small or large.\n    ";
static PyMethodDef __pyx_mdef_9GatEngine_13getNPTwoSidedPValueFast = {__Pyx_NAMESTR("getNPTwoSidedPValueFast"), (PyCFunction)__pyx_pw_9GatEngine_13getNPTwoSidedPValueFast, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12getNPTwoSidedPValueFast)};
static PyObject *__pyx_pw_9GatEngine_13getNPTwoSidedPValueFast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_ar = 0;
  double __pyx_v_val;
  double __pyx_v_mean;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getNPTwoSidedPValueFast (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ar,&__pyx_n_s__val,&__pyx_n_s__mean,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ar)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__val)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getNPTwoSidedPValueFast", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getNPTwoSidedPValueFast", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getNPTwoSidedPValueFast") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_ar = ((PyArrayObject *)values[0]);
    __pyx_v_val = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_val == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_mean = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_mean == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getNPTwoSidedPValueFast", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.getNPTwoSidedPValueFast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ar), __pyx_ptype_5numpy_ndarray, 1, "ar", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_9GatEngine_12getNPTwoSidedPValueFast(__pyx_self, __pyx_v_ar, __pyx_v_val, __pyx_v_mean);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1454
 * 
 * @cython.boundscheck(False)
 * def getNPTwoSidedPValueFast( numpy.ndarray[DTYPE_FLOAT_t, ndim=1] ar,             # <<<<<<<<<<<<<<
 *                            double val,
 *                            double mean ):
 */

static PyObject *__pyx_pf_9GatEngine_12getNPTwoSidedPValueFast(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ar, double __pyx_v_val, double __pyx_v_mean) {
  __pyx_t_14GatSegmentList_Position __pyx_v_l;
  __pyx_t_14GatSegmentList_Position __pyx_v_x;
  double __pyx_v_min_pval;
  double __pyx_v_pval;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ar;
  __Pyx_Buffer __pyx_pybuffer_ar;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  __pyx_t_14GatSegmentList_Position __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  __pyx_t_14GatSegmentList_Position __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNPTwoSidedPValueFast", 0);
  __pyx_pybuffer_ar.pybuffer.buf = NULL;
  __pyx_pybuffer_ar.refcount = 0;
  __pyx_pybuffernd_ar.data = NULL;
  __pyx_pybuffernd_ar.rcbuffer = &__pyx_pybuffer_ar;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ar.rcbuffer->pybuffer, (PyObject*)__pyx_v_ar, &__Pyx_TypeInfo_nn___pyx_t_9GatEngine_DTYPE_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_ar.diminfo[0].strides = __pyx_pybuffernd_ar.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ar.diminfo[0].shape = __pyx_pybuffernd_ar.rcbuffer->pybuffer.shape[0];

  /* "GatEngine.pyx":1464
 *     cdef double min_pval, pval
 * 
 *     l = len(ar)             # <<<<<<<<<<<<<<
 *     min_pval = 1.0 / l
 * 
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_ar)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_1;

  /* "GatEngine.pyx":1465
 * 
 *     l = len(ar)
 *     min_pval = 1.0 / l             # <<<<<<<<<<<<<<
 * 
 *     if val > mean:
 */
  if (unlikely(__pyx_v_l == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_min_pval = (1.0 / __pyx_v_l);

  /* "GatEngine.pyx":1467
 *     min_pval = 1.0 / l
 * 
 *     if val > mean:             # <<<<<<<<<<<<<<
 *         x = 0
 *         while x < l and ar[x] < val: x += 1
 */
  __pyx_t_2 = (__pyx_v_val > __pyx_v_mean);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1468
 * 
 *     if val > mean:
 *         x = 0             # <<<<<<<<<<<<<<
 *         while x < l and ar[x] < val: x += 1
 *         pval = float(x) / l
 */
    __pyx_v_x = 0;

    /* "GatEngine.pyx":1469
 *     if val > mean:
 *         x = 0
 *         while x < l and ar[x] < val: x += 1             # <<<<<<<<<<<<<<
 *         pval = float(x) / l
 *     else:
 */
    while (1) {
      __pyx_t_2 = (__pyx_v_x < __pyx_v_l);
      if (__pyx_t_2) {
        __pyx_t_3 = __pyx_v_x;
        __pyx_t_4 = ((*__Pyx_BufPtrStrided1d(__pyx_t_9GatEngine_DTYPE_FLOAT_t *, __pyx_pybuffernd_ar.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_ar.diminfo[0].strides)) < __pyx_v_val);
        __pyx_t_5 = __pyx_t_4;
      } else {
        __pyx_t_5 = __pyx_t_2;
      }
      if (!__pyx_t_5) break;
      __pyx_v_x = (__pyx_v_x + 1);
    }

    /* "GatEngine.pyx":1470
 *         x = 0
 *         while x < l and ar[x] < val: x += 1
 *         pval = float(x) / l             # <<<<<<<<<<<<<<
 *     else:
 *         x = l - 1
 */
    if (unlikely(__pyx_v_l == 0)) {
      PyErr_Format(PyExc_ZeroDivisionError, "float division");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_pval = (((double)__pyx_v_x) / __pyx_v_l);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1472
 *         pval = float(x) / l
 *     else:
 *         x = l - 1             # <<<<<<<<<<<<<<
 *         while x >= 0 and ar[x] > val: x -= 1
 *         pval = 1.0 - float(x) / l
 */
    __pyx_v_x = (__pyx_v_l - 1);

    /* "GatEngine.pyx":1473
 *     else:
 *         x = l - 1
 *         while x >= 0 and ar[x] > val: x -= 1             # <<<<<<<<<<<<<<
 *         pval = 1.0 - float(x) / l
 * 
 */
    while (1) {
      __pyx_t_5 = (__pyx_v_x >= 0);
      if (__pyx_t_5) {
        __pyx_t_6 = __pyx_v_x;
        __pyx_t_2 = ((*__Pyx_BufPtrStrided1d(__pyx_t_9GatEngine_DTYPE_FLOAT_t *, __pyx_pybuffernd_ar.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_ar.diminfo[0].strides)) > __pyx_v_val);
        __pyx_t_4 = __pyx_t_2;
      } else {
        __pyx_t_4 = __pyx_t_5;
      }
      if (!__pyx_t_4) break;
      __pyx_v_x = (__pyx_v_x - 1);
    }

    /* "GatEngine.pyx":1474
 *         x = l - 1
 *         while x >= 0 and ar[x] > val: x -= 1
 *         pval = 1.0 - float(x) / l             # <<<<<<<<<<<<<<
 * 
 *     return dmax( min_pval, pval )
 */
    if (unlikely(__pyx_v_l == 0)) {
      PyErr_Format(PyExc_ZeroDivisionError, "float division");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_pval = (1.0 - (((double)__pyx_v_x) / __pyx_v_l));
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1476
 *         pval = 1.0 - float(x) / l
 * 
 *     return dmax( min_pval, pval )             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyFloat_FromDouble(__pyx_f_9GatEngine_dmax(__pyx_v_min_pval, __pyx_v_pval)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ar.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("GatEngine.getNPTwoSidedPValueFast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ar.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1497
 *     double qvalue
 * 
 * cdef double getTwoSidedPValue( EnrichmentStatistics * stats,             # <<<<<<<<<<<<<<
 *                                double val ):
 *     '''return pvalue for *val* within sorted array *ar*
 */

static double __pyx_f_9GatEngine_getTwoSidedPValue(__pyx_t_9GatEngine_EnrichmentStatistics *__pyx_v_stats, double __pyx_v_val) {
  long __pyx_v_idx;
  long __pyx_v_l;
  double __pyx_v_min_pval;
  double __pyx_v_pval;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getTwoSidedPValue", 0);

  /* "GatEngine.pyx":1510
 *                            sizeof(double),
 *                            &val,
 *                            &cmpDouble,             # <<<<<<<<<<<<<<
 *                         )
 * 
 */
  __pyx_v_idx = searchargsorted(__pyx_v_stats->samples, __pyx_v_stats->sorted2sample, __pyx_v_stats->nsamples, (sizeof(double)), (&__pyx_v_val), (&__pyx_f_9GatEngine_cmpDouble));

  /* "GatEngine.pyx":1513
 *                         )
 * 
 *     l = stats.nsamples             # <<<<<<<<<<<<<<
 *     min_pval = 1.0 / l
 * 
 */
  __pyx_t_1 = __pyx_v_stats->nsamples;
  __pyx_v_l = __pyx_t_1;

  /* "GatEngine.pyx":1514
 * 
 *     l = stats.nsamples
 *     min_pval = 1.0 / l             # <<<<<<<<<<<<<<
 * 
 *     if idx == l:
 */
  if (unlikely(__pyx_v_l == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_min_pval = (1.0 / __pyx_v_l);

  /* "GatEngine.pyx":1516
 *     min_pval = 1.0 / l
 * 
 *     if idx == l:             # <<<<<<<<<<<<<<
 *         idx = 1
 *     elif val > stats.expected :
 */
  __pyx_t_2 = (__pyx_v_idx == __pyx_v_l);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1517
 * 
 *     if idx == l:
 *         idx = 1             # <<<<<<<<<<<<<<
 *     elif val > stats.expected :
 *         # over-representation
 */
    __pyx_v_idx = 1;
    goto __pyx_L3;
  }

  /* "GatEngine.pyx":1518
 *     if idx == l:
 *         idx = 1
 *     elif val > stats.expected :             # <<<<<<<<<<<<<<
 *         # over-representation
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val: idx -= 1
 */
  __pyx_t_2 = (__pyx_v_val > __pyx_v_stats->expected);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1520
 *     elif val > stats.expected :
 *         # over-representation
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val: idx -= 1             # <<<<<<<<<<<<<<
 *         idx = l - (idx+1)
 *     else:
 */
    while (1) {
      __pyx_t_2 = (__pyx_v_idx > 0);
      if (__pyx_t_2) {
        __pyx_t_3 = ((__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_idx])]) == __pyx_v_val);
        __pyx_t_4 = __pyx_t_3;
      } else {
        __pyx_t_4 = __pyx_t_2;
      }
      if (!__pyx_t_4) break;
      __pyx_v_idx = (__pyx_v_idx - 1);
    }

    /* "GatEngine.pyx":1521
 *         # over-representation
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val: idx -= 1
 *         idx = l - (idx+1)             # <<<<<<<<<<<<<<
 *     else:
 *         # under-representation
 */
    __pyx_v_idx = (__pyx_v_l - (__pyx_v_idx + 1));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1524
 *     else:
 *         # under-representation
 *         while idx < l and stats.samples[stats.sorted2sample[idx]] == val:             # <<<<<<<<<<<<<<
 *             idx += 1
 *         # no -1 because of 0-based indices
 */
    while (1) {
      __pyx_t_4 = (__pyx_v_idx < __pyx_v_l);
      if (__pyx_t_4) {
        __pyx_t_2 = ((__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_idx])]) == __pyx_v_val);
        __pyx_t_3 = __pyx_t_2;
      } else {
        __pyx_t_3 = __pyx_t_4;
      }
      if (!__pyx_t_3) break;

      /* "GatEngine.pyx":1525
 *         # under-representation
 *         while idx < l and stats.samples[stats.sorted2sample[idx]] == val:
 *             idx += 1             # <<<<<<<<<<<<<<
 *         # no -1 because of 0-based indices
 * 
 */
      __pyx_v_idx = (__pyx_v_idx + 1);
    }
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1528
 *         # no -1 because of 0-based indices
 * 
 *     pval = float(idx) / l             # <<<<<<<<<<<<<<
 * 
 *     return dmax( min_pval, pval)
 */
  if (unlikely(__pyx_v_l == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_pval = (((double)__pyx_v_idx) / __pyx_v_l);

  /* "GatEngine.pyx":1530
 *     pval = float(idx) / l
 * 
 *     return dmax( min_pval, pval)             # <<<<<<<<<<<<<<
 * 
 * cdef void compressSampleIndex( EnrichmentStatistics * stats ):
 */
  __pyx_r = __pyx_f_9GatEngine_dmax(__pyx_v_min_pval, __pyx_v_pval);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("GatEngine.getTwoSidedPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1532
 *     return dmax( min_pval, pval)
 * 
 * cdef void compressSampleIndex( EnrichmentStatistics * stats ):             # <<<<<<<<<<<<<<
 *     '''compress indices in stats.'''
 * 
 */

static void __pyx_f_9GatEngine_compressSampleIndex(__pyx_t_9GatEngine_EnrichmentStatistics *__pyx_v_stats) {
  int __pyx_v_x;
  int __pyx_v_refidx;
  int __pyx_v_observed_idx;
  double __pyx_v_lastval;
  double __pyx_v_thisval;
  __pyx_t_14GatSegmentList_Position __pyx_v_l;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("compressSampleIndex", 0);

  /* "GatEngine.pyx":1538
 *     cdef double lastval, thisval
 *     cdef Position l
 *     l = stats.nsamples             # <<<<<<<<<<<<<<
 * 
 *     # normalize - equal values will get the same index
 */
  __pyx_t_1 = __pyx_v_stats->nsamples;
  __pyx_v_l = __pyx_t_1;

  /* "GatEngine.pyx":1555
 *     # locate midpoint differentiating over and under-represneted
 *     # observed_idx = index of element with first sample > observed
 *     observed_idx = 0             # <<<<<<<<<<<<<<
 *     while observed_idx < l and stats.samples[stats.sorted2sample[observed_idx]] <= stats.observed:
 *         observed_idx += 1
 */
  __pyx_v_observed_idx = 0;

  /* "GatEngine.pyx":1556
 *     # observed_idx = index of element with first sample > observed
 *     observed_idx = 0
 *     while observed_idx < l and stats.samples[stats.sorted2sample[observed_idx]] <= stats.observed:             # <<<<<<<<<<<<<<
 *         observed_idx += 1
 * 
 */
  while (1) {
    __pyx_t_2 = (__pyx_v_observed_idx < __pyx_v_l);
    if (__pyx_t_2) {
      __pyx_t_3 = ((__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_observed_idx])]) <= __pyx_v_stats->observed);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    if (!__pyx_t_4) break;

    /* "GatEngine.pyx":1557
 *     observed_idx = 0
 *     while observed_idx < l and stats.samples[stats.sorted2sample[observed_idx]] <= stats.observed:
 *         observed_idx += 1             # <<<<<<<<<<<<<<
 * 
 *     # print "obs_idx=", observed_idx, "observed=", observed
 */
    __pyx_v_observed_idx = (__pyx_v_observed_idx + 1);
  }

  /* "GatEngine.pyx":1560
 * 
 *     # print "obs_idx=", observed_idx, "observed=", observed
 *     x = observed_idx - 1             # <<<<<<<<<<<<<<
 *     lastval = stats.samples[stats.sorted2sample[x]]
 *     refidx = x
 */
  __pyx_v_x = (__pyx_v_observed_idx - 1);

  /* "GatEngine.pyx":1561
 *     # print "obs_idx=", observed_idx, "observed=", observed
 *     x = observed_idx - 1
 *     lastval = stats.samples[stats.sorted2sample[x]]             # <<<<<<<<<<<<<<
 *     refidx = x
 * 
 */
  __pyx_v_lastval = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_x])]);

  /* "GatEngine.pyx":1562
 *     x = observed_idx - 1
 *     lastval = stats.samples[stats.sorted2sample[x]]
 *     refidx = x             # <<<<<<<<<<<<<<
 * 
 *     while x >= 0:
 */
  __pyx_v_refidx = __pyx_v_x;

  /* "GatEngine.pyx":1564
 *     refidx = x
 * 
 *     while x >= 0:             # <<<<<<<<<<<<<<
 *         # print "l", x
 *         thisval = stats.samples[stats.sorted2sample[x]]
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_x >= 0);
    if (!__pyx_t_4) break;

    /* "GatEngine.pyx":1566
 *     while x >= 0:
 *         # print "l", x
 *         thisval = stats.samples[stats.sorted2sample[x]]             # <<<<<<<<<<<<<<
 * 
 *         if thisval != lastval:
 */
    __pyx_v_thisval = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_x])]);

    /* "GatEngine.pyx":1568
 *         thisval = stats.samples[stats.sorted2sample[x]]
 * 
 *         if thisval != lastval:             # <<<<<<<<<<<<<<
 *             lastval = thisval
 *             refidx = x
 */
    __pyx_t_4 = (__pyx_v_thisval != __pyx_v_lastval);
    if (__pyx_t_4) {

      /* "GatEngine.pyx":1569
 * 
 *         if thisval != lastval:
 *             lastval = thisval             # <<<<<<<<<<<<<<
 *             refidx = x
 * 
 */
      __pyx_v_lastval = __pyx_v_thisval;

      /* "GatEngine.pyx":1570
 *         if thisval != lastval:
 *             lastval = thisval
 *             refidx = x             # <<<<<<<<<<<<<<
 * 
 *         stats.sample2sorted[stats.sorted2sample[x]] = refidx
 */
      __pyx_v_refidx = __pyx_v_x;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "GatEngine.pyx":1572
 *             refidx = x
 * 
 *         stats.sample2sorted[stats.sorted2sample[x]] = refidx             # <<<<<<<<<<<<<<
 *         x -= 1
 * 
 */
    (__pyx_v_stats->sample2sorted[(__pyx_v_stats->sorted2sample[__pyx_v_x])]) = __pyx_v_refidx;

    /* "GatEngine.pyx":1573
 * 
 *         stats.sample2sorted[stats.sorted2sample[x]] = refidx
 *         x -= 1             # <<<<<<<<<<<<<<
 * 
 *     x = observed_idx
 */
    __pyx_v_x = (__pyx_v_x - 1);
  }

  /* "GatEngine.pyx":1575
 *         x -= 1
 * 
 *     x = observed_idx             # <<<<<<<<<<<<<<
 *     lastval = stats.samples[stats.sorted2sample[x]]
 *     refidx = x
 */
  __pyx_v_x = __pyx_v_observed_idx;

  /* "GatEngine.pyx":1576
 * 
 *     x = observed_idx
 *     lastval = stats.samples[stats.sorted2sample[x]]             # <<<<<<<<<<<<<<
 *     refidx = x
 * 
 */
  __pyx_v_lastval = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_x])]);

  /* "GatEngine.pyx":1577
 *     x = observed_idx
 *     lastval = stats.samples[stats.sorted2sample[x]]
 *     refidx = x             # <<<<<<<<<<<<<<
 * 
 *     while x < l:
 */
  __pyx_v_refidx = __pyx_v_x;

  /* "GatEngine.pyx":1579
 *     refidx = x
 * 
 *     while x < l:             # <<<<<<<<<<<<<<
 *         # print "r", x
 *         thisval = stats.samples[stats.sorted2sample[x]]
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_x < __pyx_v_l);
    if (!__pyx_t_4) break;

    /* "GatEngine.pyx":1581
 *     while x < l:
 *         # print "r", x
 *         thisval = stats.samples[stats.sorted2sample[x]]             # <<<<<<<<<<<<<<
 *         if thisval != lastval:
 *             lastval = thisval
 */
    __pyx_v_thisval = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_x])]);

    /* "GatEngine.pyx":1582
 *         # print "r", x
 *         thisval = stats.samples[stats.sorted2sample[x]]
 *         if thisval != lastval:             # <<<<<<<<<<<<<<
 *             lastval = thisval
 *             refidx = x
 */
    __pyx_t_4 = (__pyx_v_thisval != __pyx_v_lastval);
    if (__pyx_t_4) {

      /* "GatEngine.pyx":1583
 *         thisval = stats.samples[stats.sorted2sample[x]]
 *         if thisval != lastval:
 *             lastval = thisval             # <<<<<<<<<<<<<<
 *             refidx = x
 * 
 */
      __pyx_v_lastval = __pyx_v_thisval;

      /* "GatEngine.pyx":1584
 *         if thisval != lastval:
 *             lastval = thisval
 *             refidx = x             # <<<<<<<<<<<<<<
 * 
 *         stats.sample2sorted[stats.sorted2sample[x]] = refidx
 */
      __pyx_v_refidx = __pyx_v_x;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "GatEngine.pyx":1586
 *             refidx = x
 * 
 *         stats.sample2sorted[stats.sorted2sample[x]] = refidx             # <<<<<<<<<<<<<<
 *         x += 1
 * 
 */
    (__pyx_v_stats->sample2sorted[(__pyx_v_stats->sorted2sample[__pyx_v_x])]) = __pyx_v_refidx;

    /* "GatEngine.pyx":1587
 * 
 *         stats.sample2sorted[stats.sorted2sample[x]] = refidx
 *         x += 1             # <<<<<<<<<<<<<<
 * 
 * cdef EnrichmentStatistics * makeEnrichmentStatistics( observed, samples,
 */
    __pyx_v_x = (__pyx_v_x + 1);
  }

  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":1589
 *         x += 1
 * 
 * cdef EnrichmentStatistics * makeEnrichmentStatistics( observed, samples,             # <<<<<<<<<<<<<<
 *                                                       reference,
 *                                                       pseudo_count ):
 */

static __pyx_t_9GatEngine_EnrichmentStatistics *__pyx_f_9GatEngine_makeEnrichmentStatistics(PyObject *__pyx_v_observed, PyObject *__pyx_v_samples, PyObject *__pyx_v_reference, PyObject *__pyx_v_pseudo_count) {
  __pyx_t_9GatEngine_EnrichmentStatistics *__pyx_v_stats;
  __pyx_t_14GatSegmentList_Position __pyx_v_offset;
  __pyx_t_14GatSegmentList_Position __pyx_v_i;
  __pyx_t_14GatSegmentList_Position __pyx_v_l;
  PyObject *__pyx_v_r = NULL;
  __pyx_t_9GatEngine_EnrichmentStatistics *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  __pyx_t_14GatSegmentList_Position __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("makeEnrichmentStatistics", 0);

  /* "GatEngine.pyx":1596
 *     cdef Position offset, i, l
 * 
 *     l = len(samples)             # <<<<<<<<<<<<<<
 *     if l < 1:
 *         raise ValueError( "not enough samples - no stats in makeEnrichmentStatistics" )
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_samples); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_1;

  /* "GatEngine.pyx":1597
 * 
 *     l = len(samples)
 *     if l < 1:             # <<<<<<<<<<<<<<
 *         raise ValueError( "not enough samples - no stats in makeEnrichmentStatistics" )
 * 
 */
  __pyx_t_2 = (__pyx_v_l < 1);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1598
 *     l = len(samples)
 *     if l < 1:
 *         raise ValueError( "not enough samples - no stats in makeEnrichmentStatistics" )             # <<<<<<<<<<<<<<
 * 
 *     stats = <EnrichmentStatistics*>malloc( sizeof(EnrichmentStatistics) )
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1600
 *         raise ValueError( "not enough samples - no stats in makeEnrichmentStatistics" )
 * 
 *     stats = <EnrichmentStatistics*>malloc( sizeof(EnrichmentStatistics) )             # <<<<<<<<<<<<<<
 *     if not stats: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( EnrichmentStatistics) )
 * 
 */
  __pyx_v_stats = ((__pyx_t_9GatEngine_EnrichmentStatistics *)malloc((sizeof(__pyx_t_9GatEngine_EnrichmentStatistics))));

  /* "GatEngine.pyx":1601
 * 
 *     stats = <EnrichmentStatistics*>malloc( sizeof(EnrichmentStatistics) )
 *     if not stats: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( EnrichmentStatistics) )             # <<<<<<<<<<<<<<
 * 
 *     stats.samples = <double*>calloc( l, sizeof(double))
 */
  __pyx_t_2 = (!(__pyx_v_stats != 0));
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyInt_FromSize_t((sizeof(__pyx_t_9GatEngine_EnrichmentStatistics))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":1603
 *     if not stats: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( EnrichmentStatistics) )
 * 
 *     stats.samples = <double*>calloc( l, sizeof(double))             # <<<<<<<<<<<<<<
 *     stats.sorted2sample = <int*>calloc( l, sizeof(int))
 *     stats.sample2sorted = <int*>calloc( l, sizeof(int))
 */
  __pyx_v_stats->samples = ((double *)calloc(__pyx_v_l, (sizeof(double))));

  /* "GatEngine.pyx":1604
 * 
 *     stats.samples = <double*>calloc( l, sizeof(double))
 *     stats.sorted2sample = <int*>calloc( l, sizeof(int))             # <<<<<<<<<<<<<<
 *     stats.sample2sorted = <int*>calloc( l, sizeof(int))
 * 
 */
  __pyx_v_stats->sorted2sample = ((int *)calloc(__pyx_v_l, (sizeof(int))));

  /* "GatEngine.pyx":1605
 *     stats.samples = <double*>calloc( l, sizeof(double))
 *     stats.sorted2sample = <int*>calloc( l, sizeof(int))
 *     stats.sample2sorted = <int*>calloc( l, sizeof(int))             # <<<<<<<<<<<<<<
 * 
 *     stats.observed = observed
 */
  __pyx_v_stats->sample2sorted = ((int *)calloc(__pyx_v_l, (sizeof(int))));

  /* "GatEngine.pyx":1607
 *     stats.sample2sorted = <int*>calloc( l, sizeof(int))
 * 
 *     stats.observed = observed             # <<<<<<<<<<<<<<
 *     stats.nsamples = l
 *     for i from 0 <= i < l: stats.samples[i] = float(samples[i])
 */
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_observed); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_stats->observed = __pyx_t_5;

  /* "GatEngine.pyx":1608
 * 
 *     stats.observed = observed
 *     stats.nsamples = l             # <<<<<<<<<<<<<<
 *     for i from 0 <= i < l: stats.samples[i] = float(samples[i])
 * 
 */
  __pyx_v_stats->nsamples = __pyx_v_l;

  /* "GatEngine.pyx":1609
 *     stats.observed = observed
 *     stats.nsamples = l
 *     for i from 0 <= i < l: stats.samples[i] = float(samples[i])             # <<<<<<<<<<<<<<
 * 
 *     # create index of sorted values
 */
  __pyx_t_6 = __pyx_v_l;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_samples, __pyx_v_i, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    (__pyx_v_stats->samples[__pyx_v_i]) = __pyx_t_5;
  }

  /* "GatEngine.pyx":1612
 * 
 *     # create index of sorted values
 *     r = numpy.argsort( samples )             # <<<<<<<<<<<<<<
 * 
 *     # save map: sample_id to sort order
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__argsort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_samples);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_samples);
  __Pyx_GIVEREF(__pyx_v_samples);
  __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_r = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "GatEngine.pyx":1615
 * 
 *     # save map: sample_id to sort order
 *     for i from 0 <= i < l:             # <<<<<<<<<<<<<<
 *         stats.sample2sorted[r[i]] = i
 *         stats.sorted2sample[i] = r[i]
 */
  __pyx_t_6 = __pyx_v_l;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "GatEngine.pyx":1616
 *     # save map: sample_id to sort order
 *     for i from 0 <= i < l:
 *         stats.sample2sorted[r[i]] = i             # <<<<<<<<<<<<<<
 *         stats.sorted2sample[i] = r[i]
 * 
 */
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_r, __pyx_v_i, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    (__pyx_v_stats->sample2sorted[__pyx_t_1]) = __pyx_v_i;

    /* "GatEngine.pyx":1617
 *     for i from 0 <= i < l:
 *         stats.sample2sorted[r[i]] = i
 *         stats.sorted2sample[i] = r[i]             # <<<<<<<<<<<<<<
 * 
 *     # compressSampleIndex( stats )
 */
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_r, __pyx_v_i, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    (__pyx_v_stats->sorted2sample[__pyx_v_i]) = __pyx_t_8;
  }

  /* "GatEngine.pyx":1623
 *     # for i from 0 <= i < l:
 *     #     print i, stats.samples[i], stats.sorted2sample[i], stats.sample2sorted[i]
 *     stats.expected = numpy.mean(samples)             # <<<<<<<<<<<<<<
 * 
 *     if reference != None:
 */
  __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__mean); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_samples);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_samples);
  __Pyx_GIVEREF(__pyx_v_samples);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_stats->expected = __pyx_t_5;

  /* "GatEngine.pyx":1625
 *     stats.expected = numpy.mean(samples)
 * 
 *     if reference != None:             # <<<<<<<<<<<<<<
 *         # test against reference
 *         # move expected by fold change in the reference set
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_reference, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1628
 *         # test against reference
 *         # move expected by fold change in the reference set
 *         stats.expected *= reference.fold             # <<<<<<<<<<<<<<
 * 
 *     # optionally add pseudo_counts
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_stats->expected); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_reference, __pyx_n_s__fold); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyNumber_InPlaceMultiply(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_stats->expected = __pyx_t_5;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "GatEngine.pyx":1631
 * 
 *     # optionally add pseudo_counts
 *     if stats.expected != 0:             # <<<<<<<<<<<<<<
 *         stats.fold = (stats.observed + pseudo_count) / (stats.expected + pseudo_count)
 *     else:
 */
  __pyx_t_2 = (__pyx_v_stats->expected != 0.0);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1632
 *     # optionally add pseudo_counts
 *     if stats.expected != 0:
 *         stats.fold = (stats.observed + pseudo_count) / (stats.expected + pseudo_count)             # <<<<<<<<<<<<<<
 *     else:
 *         stats.fold = 1.0
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_stats->observed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_v_pseudo_count); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_stats->expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_v_pseudo_count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_stats->fold = __pyx_t_5;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "GatEngine.pyx":1634
 *         stats.fold = (stats.observed + pseudo_count) / (stats.expected + pseudo_count)
 *     else:
 *         stats.fold = 1.0             # <<<<<<<<<<<<<<
 * 
 *     stats.stddev = numpy.std(samples)
 */
    __pyx_v_stats->fold = 1.0;
  }
  __pyx_L10:;

  /* "GatEngine.pyx":1636
 *         stats.fold = 1.0
 * 
 *     stats.stddev = numpy.std(samples)             # <<<<<<<<<<<<<<
 * 
 *     # compute 95% confidence intervals
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__std); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_samples);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_samples);
  __Pyx_GIVEREF(__pyx_v_samples);
  __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_stats->stddev = __pyx_t_5;

  /* "GatEngine.pyx":1641
 *     # The confidence interval are the values that lie
 *     # at the 5% and 95% percentile of the samples.
 *     offset = int(0.05 * l)             # <<<<<<<<<<<<<<
 * 
 *     if offset > 0:
 */
  __pyx_v_offset = ((__pyx_t_14GatSegmentList_Position)(0.05 * __pyx_v_l));

  /* "GatEngine.pyx":1643
 *     offset = int(0.05 * l)
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         stats.lower95 = stats.samples[stats.sorted2sample[ lmin( offset, l-1) ]]
 *         stats.upper95 = stats.samples[stats.sorted2sample[ lmax( l-offset, 0) ]]
 */
  __pyx_t_2 = (__pyx_v_offset > 0);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1644
 * 
 *     if offset > 0:
 *         stats.lower95 = stats.samples[stats.sorted2sample[ lmin( offset, l-1) ]]             # <<<<<<<<<<<<<<
 *         stats.upper95 = stats.samples[stats.sorted2sample[ lmax( l-offset, 0) ]]
 *     else:
 */
    __pyx_v_stats->lower95 = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_f_9GatEngine_lmin(__pyx_v_offset, (__pyx_v_l - 1))])]);

    /* "GatEngine.pyx":1645
 *     if offset > 0:
 *         stats.lower95 = stats.samples[stats.sorted2sample[ lmin( offset, l-1) ]]
 *         stats.upper95 = stats.samples[stats.sorted2sample[ lmax( l-offset, 0) ]]             # <<<<<<<<<<<<<<
 *     else:
 *         stats.lower95 = stats.samples[stats.sorted2sample[ 0 ]]
 */
    __pyx_v_stats->upper95 = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_f_9GatEngine_lmax((__pyx_v_l - __pyx_v_offset), 0)])]);
    goto __pyx_L11;
  }
  /*else*/ {

    /* "GatEngine.pyx":1647
 *         stats.upper95 = stats.samples[stats.sorted2sample[ lmax( l-offset, 0) ]]
 *     else:
 *         stats.lower95 = stats.samples[stats.sorted2sample[ 0 ]]             # <<<<<<<<<<<<<<
 *         stats.upper95 = stats.samples[stats.sorted2sample[ l-1 ]]
 * 
 */
    __pyx_v_stats->lower95 = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[0])]);

    /* "GatEngine.pyx":1648
 *     else:
 *         stats.lower95 = stats.samples[stats.sorted2sample[ 0 ]]
 *         stats.upper95 = stats.samples[stats.sorted2sample[ l-1 ]]             # <<<<<<<<<<<<<<
 * 
 *     # adjust confidence intervals for reference fold change
 */
    __pyx_v_stats->upper95 = (__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[(__pyx_v_l - 1)])]);
  }
  __pyx_L11:;

  /* "GatEngine.pyx":1652
 *     # adjust confidence intervals for reference fold change
 *     # NB: I am not sure that this is proper
 *     if reference == None:             # <<<<<<<<<<<<<<
 *         stats.pvalue = getTwoSidedPValue( stats, stats.observed )
 *     else:
 */
  __pyx_t_7 = PyObject_RichCompare(__pyx_v_reference, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1653
 *     # NB: I am not sure that this is proper
 *     if reference == None:
 *         stats.pvalue = getTwoSidedPValue( stats, stats.observed )             # <<<<<<<<<<<<<<
 *     else:
 *         # compute adjusted pvalue. Conceptually, move the distribution to center around
 */
    __pyx_v_stats->pvalue = __pyx_f_9GatEngine_getTwoSidedPValue(__pyx_v_stats, __pyx_v_stats->observed);
    goto __pyx_L12;
  }
  /*else*/ {

    /* "GatEngine.pyx":1658
 *         # expected instead of the mean. Instead of moving the distribution, simply changing
 *         # the observed value is equivalent
 *         if reference.fold > 0:             # <<<<<<<<<<<<<<
 *             stats.pvalue = getTwoSidedPValue( stats, stats.observed / reference.fold )
 *         else:
 */
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_reference, __pyx_n_s__fold); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_7, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "GatEngine.pyx":1659
 *         # the observed value is equivalent
 *         if reference.fold > 0:
 *             stats.pvalue = getTwoSidedPValue( stats, stats.observed / reference.fold )             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError( "0 fold change not applicable" )
 */
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_stats->observed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = PyObject_GetAttr(__pyx_v_reference, __pyx_n_s__fold); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_stats->pvalue = __pyx_f_9GatEngine_getTwoSidedPValue(__pyx_v_stats, __pyx_t_5);
      goto __pyx_L13;
    }
    /*else*/ {

      /* "GatEngine.pyx":1661
 *             stats.pvalue = getTwoSidedPValue( stats, stats.observed / reference.fold )
 *         else:
 *             raise ValueError( "0 fold change not applicable" )             # <<<<<<<<<<<<<<
 * 
 *         # this is analogous to shifting the excepted value.
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L13:;

    /* "GatEngine.pyx":1665
 *         # this is analogous to shifting the excepted value.
 *         # Is this correct?
 *         stats.lower95 *= reference.fold             # <<<<<<<<<<<<<<
 *         stats.upper95 *= reference.fold
 * 
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_stats->lower95); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_reference, __pyx_n_s__fold); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyNumber_InPlaceMultiply(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_stats->lower95 = __pyx_t_5;

    /* "GatEngine.pyx":1666
 *         # Is this correct?
 *         stats.lower95 *= reference.fold
 *         stats.upper95 *= reference.fold             # <<<<<<<<<<<<<<
 * 
 *     stats.qvalue = 1.0
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_stats->upper95); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_reference, __pyx_n_s__fold); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_stats->upper95 = __pyx_t_5;
  }
  __pyx_L12:;

  /* "GatEngine.pyx":1668
 *         stats.upper95 *= reference.fold
 * 
 *     stats.qvalue = 1.0             # <<<<<<<<<<<<<<
 * 
 *     return stats
 */
  __pyx_v_stats->qvalue = 1.0;

  /* "GatEngine.pyx":1670
 *     stats.qvalue = 1.0
 * 
 *     return stats             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_r = __pyx_v_stats;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("GatEngine.makeEnrichmentStatistics", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_15AnnotatorResult_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_15AnnotatorResult_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_annotation = 0;
  PyObject *__pyx_v_counter = 0;
  PyObject *__pyx_v_observed = 0;
  PyObject *__pyx_v_samples = 0;
  PyObject *__pyx_v_reference = 0;
  PyObject *__pyx_v_pseudo_count = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__annotation,&__pyx_n_s__counter,&__pyx_n_s__observed,&__pyx_n_s__samples,&__pyx_n_s__reference,&__pyx_n_s__pseudo_count,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};

    /* "GatEngine.pyx":1710
 *                   observed,
 *                   samples,
 *                   reference = None,             # <<<<<<<<<<<<<<
 *                   pseudo_count = 1.0 ):
 *         self.track = track
 */
    values[5] = ((PyObject *)Py_None);
    values[6] = __pyx_k_25;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__counter)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__observed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samples)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pseudo_count);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_track = values[0];
    __pyx_v_annotation = values[1];
    __pyx_v_counter = values[2];
    __pyx_v_observed = values[3];
    __pyx_v_samples = values[4];
    __pyx_v_reference = values[5];
    __pyx_v_pseudo_count = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult___init__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), __pyx_v_track, __pyx_v_annotation, __pyx_v_counter, __pyx_v_observed, __pyx_v_samples, __pyx_v_reference, __pyx_v_pseudo_count);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1704
 *         str track, annotation, counter
 * 
 *     def __init__( self,             # <<<<<<<<<<<<<<
 *                   track,
 *                   annotation,
 */

static int __pyx_pf_9GatEngine_15AnnotatorResult___init__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_annotation, PyObject *__pyx_v_counter, PyObject *__pyx_v_observed, PyObject *__pyx_v_samples, PyObject *__pyx_v_reference, PyObject *__pyx_v_pseudo_count) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":1712
 *                   reference = None,
 *                   pseudo_count = 1.0 ):
 *         self.track = track             # <<<<<<<<<<<<<<
 *         self.annotation = annotation
 *         self.counter = counter
 */
  if (!(likely(PyString_CheckExact(__pyx_v_track))||((__pyx_v_track) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_track)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_GOTREF(__pyx_v_self->track);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->track));
  __pyx_v_self->track = ((PyObject*)__pyx_v_track);

  /* "GatEngine.pyx":1713
 *                   pseudo_count = 1.0 ):
 *         self.track = track
 *         self.annotation = annotation             # <<<<<<<<<<<<<<
 *         self.counter = counter
 *         self.stats = makeEnrichmentStatistics( observed,
 */
  if (!(likely(PyString_CheckExact(__pyx_v_annotation))||((__pyx_v_annotation) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_annotation)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_annotation);
  __Pyx_GIVEREF(__pyx_v_annotation);
  __Pyx_GOTREF(__pyx_v_self->annotation);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->annotation));
  __pyx_v_self->annotation = ((PyObject*)__pyx_v_annotation);

  /* "GatEngine.pyx":1714
 *         self.track = track
 *         self.annotation = annotation
 *         self.counter = counter             # <<<<<<<<<<<<<<
 *         self.stats = makeEnrichmentStatistics( observed,
 *                                                samples,
 */
  if (!(likely(PyString_CheckExact(__pyx_v_counter))||((__pyx_v_counter) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_counter)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_counter);
  __Pyx_GIVEREF(__pyx_v_counter);
  __Pyx_GOTREF(__pyx_v_self->counter);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->counter));
  __pyx_v_self->counter = ((PyObject*)__pyx_v_counter);

  /* "GatEngine.pyx":1715
 *         self.annotation = annotation
 *         self.counter = counter
 *         self.stats = makeEnrichmentStatistics( observed,             # <<<<<<<<<<<<<<
 *                                                samples,
 *                                                reference,
 */
  __pyx_v_self->stats = __pyx_f_9GatEngine_makeEnrichmentStatistics(__pyx_v_observed, __pyx_v_samples, __pyx_v_reference, __pyx_v_pseudo_count);

  /* "GatEngine.pyx":1720
 *                                                pseudo_count )
 * 
 *         self.format_observed = "%i"             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_26));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_26));
  __Pyx_GOTREF(__pyx_v_self->format_observed);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->format_observed));
  __pyx_v_self->format_observed = __pyx_kp_s_26;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_3__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_2__str__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1722
 *         self.format_observed = "%i"
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 * 
 *         # if self.stats.nsamples < 10**6:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_2__str__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_v_logfold = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "GatEngine.pyx":1729
 *         #     format_pvalue = "%7.6e"
 * 
 *         if self.stats.fold > 0:             # <<<<<<<<<<<<<<
 *             logfold = self.format_fold % math.log( self.stats.fold, 2 )
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->stats->fold > 0.0);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":1730
 * 
 *         if self.stats.fold > 0:
 *             logfold = self.format_fold % math.log( self.stats.fold, 2 )             # <<<<<<<<<<<<<<
 *         else:
 *             logfold = "-inf"
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_fold); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->stats->fold); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_int_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_2);
    __Pyx_GIVEREF(__pyx_int_2);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_logfold = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1732
 *             logfold = self.format_fold % math.log( self.stats.fold, 2 )
 *         else:
 *             logfold = "-inf"             # <<<<<<<<<<<<<<
 * 
 *         return "\t".join( (self.track,
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_27));
    __pyx_v_logfold = ((PyObject *)__pyx_kp_s_27);
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1734
 *             logfold = "-inf"
 * 
 *         return "\t".join( (self.track,             # <<<<<<<<<<<<<<
 *                            self.annotation,
 *                            self.format_observed % self.stats.observed,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_28), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "GatEngine.pyx":1736
 *         return "\t".join( (self.track,
 *                            self.annotation,
 *                            self.format_observed % self.stats.observed,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.expected,
 *                            self.format_expected % self.stats.lower95,
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->stats->observed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_v_self->format_observed), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1737
 *                            self.annotation,
 *                            self.format_observed % self.stats.observed,
 *                            self.format_expected % self.stats.expected,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.lower95,
 *                            self.format_expected % self.stats.upper95,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->stats->expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1738
 *                            self.format_observed % self.stats.observed,
 *                            self.format_expected % self.stats.expected,
 *                            self.format_expected % self.stats.lower95,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.upper95,
 *                            self.format_expected % self.stats.stddev,
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->stats->lower95); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1739
 *                            self.format_expected % self.stats.expected,
 *                            self.format_expected % self.stats.lower95,
 *                            self.format_expected % self.stats.upper95,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.stddev,
 *                            self.format_fold % self.stats.fold,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->stats->upper95); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1740
 *                            self.format_expected % self.stats.lower95,
 *                            self.format_expected % self.stats.upper95,
 *                            self.format_expected % self.stats.stddev,             # <<<<<<<<<<<<<<
 *                            self.format_fold % self.stats.fold,
 *                            logfold,
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->stats->stddev); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1741
 *                            self.format_expected % self.stats.upper95,
 *                            self.format_expected % self.stats.stddev,
 *                            self.format_fold % self.stats.fold,             # <<<<<<<<<<<<<<
 *                            logfold,
 *                            self.format_pvalue % self.stats.pvalue,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_fold); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->stats->fold); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1743
 *                            self.format_fold % self.stats.fold,
 *                            logfold,
 *                            self.format_pvalue % self.stats.pvalue,             # <<<<<<<<<<<<<<
 *                            self.format_pvalue % self.stats.qvalue,
 *                            ) )
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_pvalue); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->stats->pvalue); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_11 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1744
 *                            logfold,
 *                            self.format_pvalue % self.stats.pvalue,
 *                            self.format_pvalue % self.stats.qvalue,             # <<<<<<<<<<<<<<
 *                            ) )
 * 
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__format_pvalue); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->stats->qvalue); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(11); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->track));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->track));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->track));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->annotation));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self->annotation));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->annotation));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_4, 7, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_v_logfold);
  PyTuple_SET_ITEM(__pyx_t_4, 8, __pyx_v_logfold);
  __Pyx_GIVEREF(__pyx_v_logfold);
  PyTuple_SET_ITEM(__pyx_t_4, 9, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_2 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_logfold);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_15AnnotatorResult_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_15AnnotatorResult_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_15AnnotatorResult_4__dealloc__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":1747
 *                            ) )
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.stats != NULL:
 *             free( self.stats.samples )
 */

static void __pyx_pf_9GatEngine_15AnnotatorResult_4__dealloc__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":1748
 * 
 *     def __dealloc__(self):
 *         if self.stats != NULL:             # <<<<<<<<<<<<<<
 *             free( self.stats.samples )
 *             free( self.stats.sorted2sample )
 */
  __pyx_t_1 = (__pyx_v_self->stats != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":1749
 *     def __dealloc__(self):
 *         if self.stats != NULL:
 *             free( self.stats.samples )             # <<<<<<<<<<<<<<
 *             free( self.stats.sorted2sample )
 *             free( self.stats.sample2sorted )
 */
    free(__pyx_v_self->stats->samples);

    /* "GatEngine.pyx":1750
 *         if self.stats != NULL:
 *             free( self.stats.samples )
 *             free( self.stats.sorted2sample )             # <<<<<<<<<<<<<<
 *             free( self.stats.sample2sorted )
 *             free( self.stats )
 */
    free(__pyx_v_self->stats->sorted2sample);

    /* "GatEngine.pyx":1751
 *             free( self.stats.samples )
 *             free( self.stats.sorted2sample )
 *             free( self.stats.sample2sorted )             # <<<<<<<<<<<<<<
 *             free( self.stats )
 * 
 */
    free(__pyx_v_self->stats->sample2sorted);

    /* "GatEngine.pyx":1752
 *             free( self.stats.sorted2sample )
 *             free( self.stats.sample2sorted )
 *             free( self.stats )             # <<<<<<<<<<<<<<
 * 
 *     property track:
 */
    free(__pyx_v_self->stats);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_5track_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_5track_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_5track___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1755
 * 
 *     property track:
 *         def __get__(self): return self.track             # <<<<<<<<<<<<<<
 * 
 *     property annotation:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_5track___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->track));
  __pyx_r = ((PyObject *)__pyx_v_self->track);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_10annotation_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_10annotation_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_10annotation___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1758
 * 
 *     property annotation:
 *         def __get__(self): return self.annotation             # <<<<<<<<<<<<<<
 * 
 *     property counter:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_10annotation___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->annotation));
  __pyx_r = ((PyObject *)__pyx_v_self->annotation);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_7counter_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_7counter_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_7counter___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1761
 * 
 *     property counter:
 *         def __get__(self): return self.counter             # <<<<<<<<<<<<<<
 * 
 *     property observed:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_7counter___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->counter));
  __pyx_r = ((PyObject *)__pyx_v_self->counter);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_8observed_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_8observed_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_8observed___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1764
 * 
 *     property observed:
 *         def __get__(self): return self.stats.observed             # <<<<<<<<<<<<<<
 * 
 *     property expected:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8observed___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->stats->observed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.observed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_8expected_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_8expected_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_8expected___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1767
 * 
 *     property expected:
 *         def __get__(self): return self.stats.expected             # <<<<<<<<<<<<<<
 * 
 *     property fold:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8expected___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->stats->expected); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.expected.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_4fold_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_4fold_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_4fold___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1770
 * 
 *     property fold:
 *         def __get__(self): return self.stats.fold             # <<<<<<<<<<<<<<
 * 
 *     property stddev:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_4fold___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->stats->fold); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.fold.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_6stddev_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_6stddev_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_6stddev___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1773
 * 
 *     property stddev:
 *         def __get__(self): return self.stats.stddev             # <<<<<<<<<<<<<<
 * 
 *     property pvalue:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6stddev___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->stats->stddev); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.stddev.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_6pvalue_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_6pvalue_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_6pvalue___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1776
 * 
 *     property pvalue:
 *         def __get__(self): return self.stats.pvalue             # <<<<<<<<<<<<<<
 *         def __set__(self, val): self.stats.pvalue = val
 * 
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6pvalue___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->stats->pvalue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.pvalue.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_15AnnotatorResult_6pvalue_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_9GatEngine_15AnnotatorResult_6pvalue_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_6pvalue_2__set__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), ((PyObject *)__pyx_v_val));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1777
 *     property pvalue:
 *         def __get__(self): return self.stats.pvalue
 *         def __set__(self, val): self.stats.pvalue = val             # <<<<<<<<<<<<<<
 * 
 *     property qvalue:
 */

static int __pyx_pf_9GatEngine_15AnnotatorResult_6pvalue_2__set__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->stats->pvalue = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.pvalue.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_6qvalue_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_6qvalue_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_6qvalue___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1780
 * 
 *     property qvalue:
 *         def __get__(self): return self.stats.qvalue             # <<<<<<<<<<<<<<
 *         def __set__(self, val): self.stats.qvalue = val
 * 
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6qvalue___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->stats->qvalue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.qvalue.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_15AnnotatorResult_6qvalue_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_9GatEngine_15AnnotatorResult_6qvalue_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_6qvalue_2__set__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), ((PyObject *)__pyx_v_val));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1781
 *     property qvalue:
 *         def __get__(self): return self.stats.qvalue
 *         def __set__(self, val): self.stats.qvalue = val             # <<<<<<<<<<<<<<
 * 
 *     property nsamples:
 */

static int __pyx_pf_9GatEngine_15AnnotatorResult_6qvalue_2__set__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_val); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->stats->qvalue = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.qvalue.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_8nsamples_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_8nsamples_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_8nsamples___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1784
 * 
 *     property nsamples:
 *         def __get__(self): return self.stats.nsamples             # <<<<<<<<<<<<<<
 * 
 *     property samples:
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8nsamples___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->stats->nsamples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.nsamples.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_7samples_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_7samples_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_7samples___get__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1787
 * 
 *     property samples:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef Position x
 *             r = numpy.zeros( self.nsamples, dtype = numpy.float )
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_7samples___get__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self) {
  __pyx_t_14GatSegmentList_Position __pyx_v_x;
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "GatEngine.pyx":1789
 *         def __get__(self):
 *             cdef Position x
 *             r = numpy.zeros( self.nsamples, dtype = numpy.float )             # <<<<<<<<<<<<<<
 *             for x from 0 <= x < self.stats.nsamples:
 *                 r[x] = self.stats.samples[x]
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__nsamples); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_r = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "GatEngine.pyx":1790
 *             cdef Position x
 *             r = numpy.zeros( self.nsamples, dtype = numpy.float )
 *             for x from 0 <= x < self.stats.nsamples:             # <<<<<<<<<<<<<<
 *                 r[x] = self.stats.samples[x]
 *             return r
 */
  __pyx_t_6 = __pyx_v_self->stats->nsamples;
  for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_6; __pyx_v_x++) {

    /* "GatEngine.pyx":1791
 *             r = numpy.zeros( self.nsamples, dtype = numpy.float )
 *             for x from 0 <= x < self.stats.nsamples:
 *                 r[x] = self.stats.samples[x]             # <<<<<<<<<<<<<<
 *             return r
 * 
 */
    __pyx_t_5 = PyFloat_FromDouble((__pyx_v_self->stats->samples[__pyx_v_x])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_SetItemInt(__pyx_v_r, __pyx_v_x, __pyx_t_5, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }

  /* "GatEngine.pyx":1792
 *             for x from 0 <= x < self.stats.nsamples:
 *                 r[x] = self.stats.samples[x]
 *             return r             # <<<<<<<<<<<<<<
 * 
 *     property format_observed:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_r);
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.samples.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_15AnnotatorResult_15format_observed_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
static int __pyx_pw_9GatEngine_15AnnotatorResult_15format_observed_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_15format_observed___set__(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), ((PyObject *)__pyx_v_f));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1795
 * 
 *     property format_observed:
 *         def __set__(self,f): self.format_observed = f             # <<<<<<<<<<<<<<
 * 
 *     def isSampleSignificantAtPvalue( self, sample_id, double pvalue ):
 */

static int __pyx_pf_9GatEngine_15AnnotatorResult_15format_observed___set__(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_f) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyString_CheckExact(__pyx_v_f))||((__pyx_v_f) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_f)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_f);
  __Pyx_GIVEREF(__pyx_v_f);
  __Pyx_GOTREF(__pyx_v_self->format_observed);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->format_observed));
  __pyx_v_self->format_observed = ((PyObject*)__pyx_v_f);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.format_observed.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_7isSampleSignificantAtPvalue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_15AnnotatorResult_6isSampleSignificantAtPvalue[] = "AnnotatorResult.isSampleSignificantAtPvalue(self, sample_id, double pvalue)";
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_7isSampleSignificantAtPvalue(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sample_id = 0;
  double __pyx_v_pvalue;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("isSampleSignificantAtPvalue (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sample_id,&__pyx_n_s__pvalue,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pvalue)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("isSampleSignificantAtPvalue", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "isSampleSignificantAtPvalue") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sample_id = values[0];
    __pyx_v_pvalue = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_pvalue == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("isSampleSignificantAtPvalue", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.isSampleSignificantAtPvalue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_6isSampleSignificantAtPvalue(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), __pyx_v_sample_id, __pyx_v_pvalue);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1797
 *         def __set__(self,f): self.format_observed = f
 * 
 *     def isSampleSignificantAtPvalue( self, sample_id, double pvalue ):             # <<<<<<<<<<<<<<
 *         return isSampleSignificantAtPvalue( self.stats, sample_id, pvalue )
 * 
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_6isSampleSignificantAtPvalue(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_sample_id, double __pyx_v_pvalue) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("isSampleSignificantAtPvalue", 0);

  /* "GatEngine.pyx":1798
 * 
 *     def isSampleSignificantAtPvalue( self, sample_id, double pvalue ):
 *         return isSampleSignificantAtPvalue( self.stats, sample_id, pvalue )             # <<<<<<<<<<<<<<
 * 
 *     def getSample( self, sample_id ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_sample_id); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_f_9GatEngine_isSampleSignificantAtPvalue(__pyx_v_self->stats, __pyx_t_1, __pyx_v_pvalue)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.isSampleSignificantAtPvalue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_9getSample(PyObject *__pyx_v_self, PyObject *__pyx_v_sample_id); /*proto*/
static char __pyx_doc_9GatEngine_15AnnotatorResult_8getSample[] = "AnnotatorResult.getSample(self, sample_id)";
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_9getSample(PyObject *__pyx_v_self, PyObject *__pyx_v_sample_id) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getSample (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_8getSample(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), ((PyObject *)__pyx_v_sample_id));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1800
 *         return isSampleSignificantAtPvalue( self.stats, sample_id, pvalue )
 * 
 *     def getSample( self, sample_id ):             # <<<<<<<<<<<<<<
 *         return self.stats.samples[sample_id]
 * 
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_8getSample(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_sample_id) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getSample", 0);

  /* "GatEngine.pyx":1801
 * 
 *     def getSample( self, sample_id ):
 *         return self.stats.samples[sample_id]             # <<<<<<<<<<<<<<
 * 
 *     def getEmpiricalPValue( self, value ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_sample_id); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_self->stats->samples[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.getSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_11getEmpiricalPValue(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_9GatEngine_15AnnotatorResult_10getEmpiricalPValue[] = "AnnotatorResult.getEmpiricalPValue(self, value)";
static PyObject *__pyx_pw_9GatEngine_15AnnotatorResult_11getEmpiricalPValue(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getEmpiricalPValue (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_15AnnotatorResult_10getEmpiricalPValue(((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1803
 *         return self.stats.samples[sample_id]
 * 
 *     def getEmpiricalPValue( self, value ):             # <<<<<<<<<<<<<<
 *         return getTwoSidedPValue( self.stats, value )
 * 
 */

static PyObject *__pyx_pf_9GatEngine_15AnnotatorResult_10getEmpiricalPValue(struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getEmpiricalPValue", 0);

  /* "GatEngine.pyx":1804
 * 
 *     def getEmpiricalPValue( self, value ):
 *         return getTwoSidedPValue( self.stats, value )             # <<<<<<<<<<<<<<
 * 
 * cdef class AnnotatorResultExtended(AnnotatorResult):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyFloat_FromDouble(__pyx_f_9GatEngine_getTwoSidedPValue(__pyx_v_self->stats, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.AnnotatorResult.getEmpiricalPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_23AnnotatorResultExtended_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_23AnnotatorResultExtended_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_annotation = 0;
  PyObject *__pyx_v_counter = 0;
  PyObject *__pyx_v_observed = 0;
  PyObject *__pyx_v_samples = 0;
  PyObject *__pyx_v_track_segments = 0;
  PyObject *__pyx_v_annotation_segments = 0;
  PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_v_reference = 0;
  PyObject *__pyx_v_pseudo_count = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__annotation,&__pyx_n_s__counter,&__pyx_n_s__observed,&__pyx_n_s__samples,&__pyx_n_s__track_segments,&__pyx_n_s__annotation_segments,&__pyx_n_s__workspace,&__pyx_n_s__reference,&__pyx_n_s__pseudo_count,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};

    /* "GatEngine.pyx":1855
 *                   annotation_segments,
 *                   workspace,
 *                   reference = None,             # <<<<<<<<<<<<<<
 *                   pseudo_count = 1.0 ):
 * 
 */
    values[8] = ((PyObject *)Py_None);
    values[9] = __pyx_k_29;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__counter)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__observed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samples)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track_segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotation_segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pseudo_count);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_track = values[0];
    __pyx_v_annotation = values[1];
    __pyx_v_counter = values[2];
    __pyx_v_observed = values[3];
    __pyx_v_samples = values[4];
    __pyx_v_track_segments = values[5];
    __pyx_v_annotation_segments = values[6];
    __pyx_v_workspace = values[7];
    __pyx_v_reference = values[8];
    __pyx_v_pseudo_count = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_23AnnotatorResultExtended___init__(((struct __pyx_obj_9GatEngine_AnnotatorResultExtended *)__pyx_v_self), __pyx_v_track, __pyx_v_annotation, __pyx_v_counter, __pyx_v_observed, __pyx_v_samples, __pyx_v_track_segments, __pyx_v_annotation_segments, __pyx_v_workspace, __pyx_v_reference, __pyx_v_pseudo_count);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1846
 *         Position workspace_size
 * 
 *     def __init__( self,             # <<<<<<<<<<<<<<
 *                   track,
 *                   annotation,
 */

static int __pyx_pf_9GatEngine_23AnnotatorResultExtended___init__(struct __pyx_obj_9GatEngine_AnnotatorResultExtended *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_annotation, PyObject *__pyx_v_counter, PyObject *__pyx_v_observed, PyObject *__pyx_v_samples, PyObject *__pyx_v_track_segments, PyObject *__pyx_v_annotation_segments, PyObject *__pyx_v_workspace, PyObject *__pyx_v_reference, PyObject *__pyx_v_pseudo_count) {
  PyObject *__pyx_v_overlap = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":1858
 *                   pseudo_count = 1.0 ):
 * 
 *         AnnotatorResult.__init__( self, track, annotation, counter, observed, samples,             # <<<<<<<<<<<<<<
 *                                   reference = reference,
 *                                   pseudo_count = pseudo_count )
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_AnnotatorResult)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_annotation);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_annotation);
  __Pyx_GIVEREF(__pyx_v_annotation);
  __Pyx_INCREF(__pyx_v_counter);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_counter);
  __Pyx_GIVEREF(__pyx_v_counter);
  __Pyx_INCREF(__pyx_v_observed);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_v_observed);
  __Pyx_GIVEREF(__pyx_v_observed);
  __Pyx_INCREF(__pyx_v_samples);
  PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_v_samples);
  __Pyx_GIVEREF(__pyx_v_samples);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));

  /* "GatEngine.pyx":1859
 * 
 *         AnnotatorResult.__init__( self, track, annotation, counter, observed, samples,
 *                                   reference = reference,             # <<<<<<<<<<<<<<
 *                                   pseudo_count = pseudo_count )
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__reference), __pyx_v_reference) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1860
 *         AnnotatorResult.__init__( self, track, annotation, counter, observed, samples,
 *                                   reference = reference,
 *                                   pseudo_count = pseudo_count )             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__pseudo_count), __pyx_v_pseudo_count) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1863
 * 
 * 
 *         self.track_nsegments = track_segments.counts()             # <<<<<<<<<<<<<<
 *         self.track_size = track_segments.sum()
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_track_segments, __pyx_n_s__counts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->track_nsegments = __pyx_t_5;

  /* "GatEngine.pyx":1864
 * 
 *         self.track_nsegments = track_segments.counts()
 *         self.track_size = track_segments.sum()             # <<<<<<<<<<<<<<
 * 
 *         self.annotation_nsegments = annotation_segments.counts()
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_track_segments, __pyx_n_s__sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->track_size = __pyx_t_5;

  /* "GatEngine.pyx":1866
 *         self.track_size = track_segments.sum()
 * 
 *         self.annotation_nsegments = annotation_segments.counts()             # <<<<<<<<<<<<<<
 *         self.annotation_size = annotation_segments.sum()
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_annotation_segments, __pyx_n_s__counts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->annotation_nsegments = __pyx_t_5;

  /* "GatEngine.pyx":1867
 * 
 *         self.annotation_nsegments = annotation_segments.counts()
 *         self.annotation_size = annotation_segments.sum()             # <<<<<<<<<<<<<<
 * 
 *         overlap = track_segments.clone()
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_annotation_segments, __pyx_n_s__sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->annotation_size = __pyx_t_5;

  /* "GatEngine.pyx":1869
 *         self.annotation_size = annotation_segments.sum()
 * 
 *         overlap = track_segments.clone()             # <<<<<<<<<<<<<<
 *         overlap.intersect( annotation_segments )
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_track_segments, __pyx_n_s__clone); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_overlap = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":1870
 * 
 *         overlap = track_segments.clone()
 *         overlap.intersect( annotation_segments )             # <<<<<<<<<<<<<<
 * 
 *         self.overlap_nsegments = overlap.counts()
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_overlap, __pyx_n_s__intersect); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_annotation_segments);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_annotation_segments);
  __Pyx_GIVEREF(__pyx_v_annotation_segments);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":1872
 *         overlap.intersect( annotation_segments )
 * 
 *         self.overlap_nsegments = overlap.counts()             # <<<<<<<<<<<<<<
 *         self.overlap_size = overlap.sum()
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_overlap, __pyx_n_s__counts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->overlap_nsegments = __pyx_t_5;

  /* "GatEngine.pyx":1873
 * 
 *         self.overlap_nsegments = overlap.counts()
 *         self.overlap_size = overlap.sum()             # <<<<<<<<<<<<<<
 * 
 *         self.workspace_size = workspace.sum()
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_overlap, __pyx_n_s__sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->overlap_size = __pyx_t_5;

  /* "GatEngine.pyx":1875
 *         self.overlap_size = overlap.sum()
 * 
 *         self.workspace_size = workspace.sum()             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_workspace, __pyx_n_s__sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->workspace_size = __pyx_t_5;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_overlap);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_23AnnotatorResultExtended_3__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_23AnnotatorResultExtended_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_23AnnotatorResultExtended_2__str__(((struct __pyx_obj_9GatEngine_AnnotatorResultExtended *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_23AnnotatorResultExtended_7__str___1_toFold(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9GatEngine_23AnnotatorResultExtended_7__str___1_toFold = {__Pyx_NAMESTR("_toFold"), (PyCFunction)__pyx_pw_9GatEngine_23AnnotatorResultExtended_7__str___1_toFold, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_9GatEngine_23AnnotatorResultExtended_7__str___1_toFold(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_toFold (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__a,&__pyx_n_s__b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_toFold", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_toFold") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_toFold", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__str__._toFold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_23AnnotatorResultExtended_7__str____toFold(__pyx_self, __pyx_v_a, __pyx_v_b);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1889
 *             logfold = "-inf"
 * 
 *         def _toFold( a, b ):             # <<<<<<<<<<<<<<
 *             if b > 0: return self.format_fold % (100.0 * float(a) / b )
 *             else: return "na"
 */

static PyObject *__pyx_pf_9GatEngine_23AnnotatorResultExtended_7__str____toFold(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *__pyx_cur_scope;
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  double __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_toFold", 0);
  __pyx_outer_scope = (struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "GatEngine.pyx":1890
 * 
 *         def _toFold( a, b ):
 *             if b > 0: return self.format_fold % (100.0 * float(a) / b )             # <<<<<<<<<<<<<<
 *             else: return "na"
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_b, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_fold); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_AsDouble(__pyx_v_a); if (unlikely(__pyx_t_3 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyFloat_FromDouble((100.0 * __pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_b); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1891
 *         def _toFold( a, b ):
 *             if b > 0: return self.format_fold % (100.0 * float(a) / b )
 *             else: return "na"             # <<<<<<<<<<<<<<
 * 
 *         def _toDensity( a, b ):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__na));
    __pyx_r = ((PyObject *)__pyx_n_s__na);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__str__._toFold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_23AnnotatorResultExtended_7__str___3_toDensity(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9GatEngine_23AnnotatorResultExtended_7__str___3_toDensity = {__Pyx_NAMESTR("_toDensity"), (PyCFunction)__pyx_pw_9GatEngine_23AnnotatorResultExtended_7__str___3_toDensity, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_9GatEngine_23AnnotatorResultExtended_7__str___3_toDensity(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_toDensity (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__a,&__pyx_n_s__b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_toDensity", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_toDensity") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_toDensity", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__str__._toDensity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_23AnnotatorResultExtended_7__str___2_toDensity(__pyx_self, __pyx_v_a, __pyx_v_b);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1893
 *             else: return "na"
 * 
 *         def _toDensity( a, b ):             # <<<<<<<<<<<<<<
 *             if b > 0: return self.format_density % (100.0 * float(a) / b )
 *             else: return "na"
 */

static PyObject *__pyx_pf_9GatEngine_23AnnotatorResultExtended_7__str___2_toDensity(PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *__pyx_cur_scope;
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  double __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_toDensity", 0);
  __pyx_outer_scope = (struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "GatEngine.pyx":1894
 * 
 *         def _toDensity( a, b ):
 *             if b > 0: return self.format_density % (100.0 * float(a) / b )             # <<<<<<<<<<<<<<
 *             else: return "na"
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_b, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_density); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_AsDouble(__pyx_v_a); if (unlikely(__pyx_t_3 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyFloat_FromDouble((100.0 * __pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_b); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1895
 *         def _toDensity( a, b ):
 *             if b > 0: return self.format_density % (100.0 * float(a) / b )
 *             else: return "na"             # <<<<<<<<<<<<<<
 * 
 *         return "\t".join( (self.track,
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__na));
    __pyx_r = ((PyObject *)__pyx_n_s__na);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__str__._toDensity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1877
 *         self.workspace_size = workspace.sum()
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 * 
 *         # if self.stats.nsamples < 10**6:
 */

static PyObject *__pyx_pf_9GatEngine_23AnnotatorResultExtended_2__str__(struct __pyx_obj_9GatEngine_AnnotatorResultExtended *__pyx_v_self) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *__pyx_cur_scope;
  PyObject *__pyx_v_logfold = NULL;
  PyObject *__pyx_v__toFold = 0;
  PyObject *__pyx_v__toDensity = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);
  __pyx_cur_scope = (struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *)__pyx_ptype_9GatEngine___pyx_scope_struct____str__->tp_new(__pyx_ptype_9GatEngine___pyx_scope_struct____str__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "GatEngine.pyx":1884
 *         #     format_pvalue = "%7.6e"
 * 
 *         if self.stats.fold > 0:             # <<<<<<<<<<<<<<
 *             logfold = self.format_fold % math.log( self.stats.fold, 2 )
 *         else:
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->fold > 0.0);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":1885
 * 
 *         if self.stats.fold > 0:
 *             logfold = self.format_fold % math.log( self.stats.fold, 2 )             # <<<<<<<<<<<<<<
 *         else:
 *             logfold = "-inf"
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_fold); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->fold); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_int_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_2);
    __Pyx_GIVEREF(__pyx_int_2);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_logfold = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1887
 *             logfold = self.format_fold % math.log( self.stats.fold, 2 )
 *         else:
 *             logfold = "-inf"             # <<<<<<<<<<<<<<
 * 
 *         def _toFold( a, b ):
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_27));
    __pyx_v_logfold = ((PyObject *)__pyx_kp_s_27);
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1889
 *             logfold = "-inf"
 * 
 *         def _toFold( a, b ):             # <<<<<<<<<<<<<<
 *             if b > 0: return self.format_fold % (100.0 * float(a) / b )
 *             else: return "na"
 */
  __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_23AnnotatorResultExtended_7__str___1_toFold, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_31)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v__toFold = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "GatEngine.pyx":1893
 *             else: return "na"
 * 
 *         def _toDensity( a, b ):             # <<<<<<<<<<<<<<
 *             if b > 0: return self.format_density % (100.0 * float(a) / b )
 *             else: return "na"
 */
  __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_23AnnotatorResultExtended_7__str___3_toDensity, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_34)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v__toDensity = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "GatEngine.pyx":1897
 *             else: return "na"
 * 
 *         return "\t".join( (self.track,             # <<<<<<<<<<<<<<
 *                            self.annotation,
 *                            self.format_observed % self.stats.observed,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_28), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "GatEngine.pyx":1899
 *         return "\t".join( (self.track,
 *                            self.annotation,
 *                            self.format_observed % self.stats.observed,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.expected,
 *                            self.format_expected % self.stats.lower95,
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->observed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.format_observed), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1900
 *                            self.annotation,
 *                            self.format_observed % self.stats.observed,
 *                            self.format_expected % self.stats.expected,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.lower95,
 *                            self.format_expected % self.stats.upper95,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1901
 *                            self.format_observed % self.stats.observed,
 *                            self.format_expected % self.stats.expected,
 *                            self.format_expected % self.stats.lower95,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.upper95,
 *                            self.format_expected % self.stats.stddev,
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->lower95); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1902
 *                            self.format_expected % self.stats.expected,
 *                            self.format_expected % self.stats.lower95,
 *                            self.format_expected % self.stats.upper95,             # <<<<<<<<<<<<<<
 *                            self.format_expected % self.stats.stddev,
 *                            self.format_fold % self.stats.fold,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->upper95); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1903
 *                            self.format_expected % self.stats.lower95,
 *                            self.format_expected % self.stats.upper95,
 *                            self.format_expected % self.stats.stddev,             # <<<<<<<<<<<<<<
 *                            self.format_fold % self.stats.fold,
 *                            logfold,
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_expected); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->stddev); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1904
 *                            self.format_expected % self.stats.upper95,
 *                            self.format_expected % self.stats.stddev,
 *                            self.format_fold % self.stats.fold,             # <<<<<<<<<<<<<<
 *                            logfold,
 *                            self.format_pvalue % self.stats.pvalue,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_fold); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->fold); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1906
 *                            self.format_fold % self.stats.fold,
 *                            logfold,
 *                            self.format_pvalue % self.stats.pvalue,             # <<<<<<<<<<<<<<
 *                            self.format_pvalue % self.stats.qvalue,
 *                            self.format_counts % self.track_nsegments,
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_pvalue); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->pvalue); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_11 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1907
 *                            logfold,
 *                            self.format_pvalue % self.stats.pvalue,
 *                            self.format_pvalue % self.stats.qvalue,             # <<<<<<<<<<<<<<
 *                            self.format_counts % self.track_nsegments,
 *                            self.format_counts % self.track_size,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_pvalue); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->__pyx_base.stats->qvalue); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1908
 *                            self.format_pvalue % self.stats.pvalue,
 *                            self.format_pvalue % self.stats.qvalue,
 *                            self.format_counts % self.track_nsegments,             # <<<<<<<<<<<<<<
 *                            self.format_counts % self.track_size,
 *                            _toDensity( self.track_size, self.workspace_size),
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_counts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->track_nsegments); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_13 = PyNumber_Remainder(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":1909
 *                            self.format_pvalue % self.stats.qvalue,
 *                            self.format_counts % self.track_nsegments,
 *                            self.format_counts % self.track_size,             # <<<<<<<<<<<<<<
 *                            _toDensity( self.track_size, self.workspace_size),
 *                            self.format_counts % self.annotation_nsegments,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_counts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->track_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_14 = PyNumber_Remainder(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1910
 *                            self.format_counts % self.track_nsegments,
 *                            self.format_counts % self.track_size,
 *                            _toDensity( self.track_size, self.workspace_size),             # <<<<<<<<<<<<<<
 *                            self.format_counts % self.annotation_nsegments,
 *                            self.format_counts % self.annotation_size,
 */
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->track_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->workspace_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_4 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_v__toDensity, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;

  /* "GatEngine.pyx":1911
 *                            self.format_counts % self.track_size,
 *                            _toDensity( self.track_size, self.workspace_size),
 *                            self.format_counts % self.annotation_nsegments,             # <<<<<<<<<<<<<<
 *                            self.format_counts % self.annotation_size,
 *                            _toDensity( self.annotation_size, self.workspace_size),
 */
  __pyx_t_15 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_counts); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->annotation_nsegments); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_16 = PyNumber_Remainder(__pyx_t_15, __pyx_t_4); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":1912
 *                            _toDensity( self.track_size, self.workspace_size),
 *                            self.format_counts % self.annotation_nsegments,
 *                            self.format_counts % self.annotation_size,             # <<<<<<<<<<<<<<
 *                            _toDensity( self.annotation_size, self.workspace_size),
 *                            self.format_counts % self.overlap_nsegments,
 */
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_counts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->annotation_size); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = PyNumber_Remainder(__pyx_t_4, __pyx_t_15); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "GatEngine.pyx":1913
 *                            self.format_counts % self.annotation_nsegments,
 *                            self.format_counts % self.annotation_size,
 *                            _toDensity( self.annotation_size, self.workspace_size),             # <<<<<<<<<<<<<<
 *                            self.format_counts % self.overlap_nsegments,
 *                            self.format_counts % self.overlap_size,
 */
  __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->annotation_size); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->workspace_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_15 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_v__toDensity, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

  /* "GatEngine.pyx":1914
 *                            self.format_counts % self.annotation_size,
 *                            _toDensity( self.annotation_size, self.workspace_size),
 *                            self.format_counts % self.overlap_nsegments,             # <<<<<<<<<<<<<<
 *                            self.format_counts % self.overlap_size,
 *                            _toDensity( self.overlap_size, self.workspace_size),
 */
  __pyx_t_18 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_counts); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_nsegments); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_19 = PyNumber_Remainder(__pyx_t_18, __pyx_t_15); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "GatEngine.pyx":1915
 *                            _toDensity( self.annotation_size, self.workspace_size),
 *                            self.format_counts % self.overlap_nsegments,
 *                            self.format_counts % self.overlap_size,             # <<<<<<<<<<<<<<
 *                            _toDensity( self.overlap_size, self.workspace_size),
 *                            _toFold( self.overlap_nsegments, self.track_nsegments ),
 */
  __pyx_t_15 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__format_counts); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_18 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_size); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_20 = PyNumber_Remainder(__pyx_t_15, __pyx_t_18); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

  /* "GatEngine.pyx":1916
 *                            self.format_counts % self.overlap_nsegments,
 *                            self.format_counts % self.overlap_size,
 *                            _toDensity( self.overlap_size, self.workspace_size),             # <<<<<<<<<<<<<<
 *                            _toFold( self.overlap_nsegments, self.track_nsegments ),
 *                            _toFold( self.overlap_size, self.track_size ),
 */
  __pyx_t_18 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_size); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->workspace_size); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_21);
  PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_18);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  __pyx_t_18 = 0;
  __pyx_t_15 = 0;
  __pyx_t_15 = PyObject_Call(__pyx_v__toDensity, ((PyObject *)__pyx_t_21), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;

  /* "GatEngine.pyx":1917
 *                            self.format_counts % self.overlap_size,
 *                            _toDensity( self.overlap_size, self.workspace_size),
 *                            _toFold( self.overlap_nsegments, self.track_nsegments ),             # <<<<<<<<<<<<<<
 *                            _toFold( self.overlap_size, self.track_size ),
 *                            _toFold( self.overlap_nsegments, self.annotation_nsegments ),
 */
  __pyx_t_21 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_nsegments); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_18 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->track_nsegments); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_22);
  PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21);
  __Pyx_GIVEREF(__pyx_t_21);
  PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_t_18);
  __Pyx_GIVEREF(__pyx_t_18);
  __pyx_t_21 = 0;
  __pyx_t_18 = 0;
  __pyx_t_18 = PyObject_Call(__pyx_v__toFold, ((PyObject *)__pyx_t_22), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(((PyObject *)__pyx_t_22)); __pyx_t_22 = 0;

  /* "GatEngine.pyx":1918
 *                            _toDensity( self.overlap_size, self.workspace_size),
 *                            _toFold( self.overlap_nsegments, self.track_nsegments ),
 *                            _toFold( self.overlap_size, self.track_size ),             # <<<<<<<<<<<<<<
 *                            _toFold( self.overlap_nsegments, self.annotation_nsegments ),
 *                            _toFold( self.overlap_size, self.annotation_size ),
 */
  __pyx_t_22 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_size); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_21 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->track_size); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_23);
  PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_22);
  __Pyx_GIVEREF(__pyx_t_22);
  PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_t_21);
  __Pyx_GIVEREF(__pyx_t_21);
  __pyx_t_22 = 0;
  __pyx_t_21 = 0;
  __pyx_t_21 = PyObject_Call(__pyx_v__toFold, ((PyObject *)__pyx_t_23), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_DECREF(((PyObject *)__pyx_t_23)); __pyx_t_23 = 0;

  /* "GatEngine.pyx":1919
 *                            _toFold( self.overlap_nsegments, self.track_nsegments ),
 *                            _toFold( self.overlap_size, self.track_size ),
 *                            _toFold( self.overlap_nsegments, self.annotation_nsegments ),             # <<<<<<<<<<<<<<
 *                            _toFold( self.overlap_size, self.annotation_size ),
 *                            ) )
 */
  __pyx_t_23 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_nsegments); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_23);
  __pyx_t_22 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->annotation_nsegments); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_24);
  PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_23);
  __Pyx_GIVEREF(__pyx_t_23);
  PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_t_22);
  __Pyx_GIVEREF(__pyx_t_22);
  __pyx_t_23 = 0;
  __pyx_t_22 = 0;
  __pyx_t_22 = PyObject_Call(__pyx_v__toFold, ((PyObject *)__pyx_t_24), NULL); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(((PyObject *)__pyx_t_24)); __pyx_t_24 = 0;

  /* "GatEngine.pyx":1920
 *                            _toFold( self.overlap_size, self.track_size ),
 *                            _toFold( self.overlap_nsegments, self.annotation_nsegments ),
 *                            _toFold( self.overlap_size, self.annotation_size ),             # <<<<<<<<<<<<<<
 *                            ) )
 * 
 */
  __pyx_t_24 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->overlap_size); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_24);
  __pyx_t_23 = PyLong_FromUnsignedLong(__pyx_cur_scope->__pyx_v_self->annotation_size); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_23);
  __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_25);
  PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_24);
  __Pyx_GIVEREF(__pyx_t_24);
  PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_t_23);
  __Pyx_GIVEREF(__pyx_t_23);
  __pyx_t_24 = 0;
  __pyx_t_23 = 0;
  __pyx_t_23 = PyObject_Call(__pyx_v__toFold, ((PyObject *)__pyx_t_25), NULL); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_23);
  __Pyx_DECREF(((PyObject *)__pyx_t_25)); __pyx_t_25 = 0;
  __pyx_t_25 = PyTuple_New(24); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_25);
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.track));
  PyTuple_SET_ITEM(__pyx_t_25, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.track));
  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.track));
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.annotation));
  PyTuple_SET_ITEM(__pyx_t_25, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.annotation));
  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->__pyx_base.annotation));
  PyTuple_SET_ITEM(__pyx_t_25, 2, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_25, 3, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_25, 4, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_25, 5, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_25, 6, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_25, 7, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_v_logfold);
  PyTuple_SET_ITEM(__pyx_t_25, 8, __pyx_v_logfold);
  __Pyx_GIVEREF(__pyx_v_logfold);
  PyTuple_SET_ITEM(__pyx_t_25, 9, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_25, 10, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_25, 11, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_25, 12, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_25, 13, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_25, 14, __pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_25, 15, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_25, 16, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_25, 17, __pyx_t_19);
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_25, 18, __pyx_t_20);
  __Pyx_GIVEREF(__pyx_t_20);
  PyTuple_SET_ITEM(__pyx_t_25, 19, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_25, 20, __pyx_t_18);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_25, 21, __pyx_t_21);
  __Pyx_GIVEREF(__pyx_t_21);
  PyTuple_SET_ITEM(__pyx_t_25, 22, __pyx_t_22);
  __Pyx_GIVEREF(__pyx_t_22);
  PyTuple_SET_ITEM(__pyx_t_25, 23, __pyx_t_23);
  __Pyx_GIVEREF(__pyx_t_23);
  __pyx_t_2 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_3 = 0;
  __pyx_t_16 = 0;
  __pyx_t_17 = 0;
  __pyx_t_4 = 0;
  __pyx_t_19 = 0;
  __pyx_t_20 = 0;
  __pyx_t_15 = 0;
  __pyx_t_18 = 0;
  __pyx_t_21 = 0;
  __pyx_t_22 = 0;
  __pyx_t_23 = 0;
  __pyx_t_23 = PyTuple_New(1); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_23);
  PyTuple_SET_ITEM(__pyx_t_23, 0, ((PyObject *)__pyx_t_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_25));
  __pyx_t_25 = 0;
  __pyx_t_25 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_23), NULL); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_25);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_23)); __pyx_t_23 = 0;
  __pyx_r = __pyx_t_25;
  __pyx_t_25 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_AddTraceback("GatEngine.AnnotatorResultExtended.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_logfold);
  __Pyx_XDECREF(__pyx_v__toFold);
  __Pyx_XDECREF(__pyx_v__toDensity);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_15getNormedPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_14getNormedPValue[] = "getNormedPValue(value, r)\nreturn pvalue assuming that samples are normal distributed.";
static PyMethodDef __pyx_mdef_9GatEngine_15getNormedPValue = {__Pyx_NAMESTR("getNormedPValue"), (PyCFunction)__pyx_pw_9GatEngine_15getNormedPValue, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_14getNormedPValue)};
static PyObject *__pyx_pw_9GatEngine_15getNormedPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_r = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getNormedPValue (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__value,&__pyx_n_s__r,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__r)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getNormedPValue", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getNormedPValue") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_value = values[0];
    __pyx_v_r = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getNormedPValue", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.getNormedPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_14getNormedPValue(__pyx_self, __pyx_v_value, __pyx_v_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1926
 * ############################################################
 * ############################################################
 * def getNormedPValue( value, r ):             # <<<<<<<<<<<<<<
 *     '''return pvalue assuming that samples are normal distributed.'''
 *     absval = abs(value - r.expected)
 */

static PyObject *__pyx_pf_9GatEngine_14getNormedPValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value, PyObject *__pyx_v_r) {
  PyObject *__pyx_v_absval = NULL;
  PyObject *__pyx_v_pvalue = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNormedPValue", 0);

  /* "GatEngine.pyx":1928
 * def getNormedPValue( value, r ):
 *     '''return pvalue assuming that samples are normal distributed.'''
 *     absval = abs(value - r.expected)             # <<<<<<<<<<<<<<
 *     if r.stddev == 0:
 *         # dummy pvalue - if no overlap in expected, pvalue is set to 1.
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__expected); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_v_value, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Absolute(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_absval = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":1929
 *     '''return pvalue assuming that samples are normal distributed.'''
 *     absval = abs(value - r.expected)
 *     if r.stddev == 0:             # <<<<<<<<<<<<<<
 *         # dummy pvalue - if no overlap in expected, pvalue is set to 1.
 *         pvalue = 1.0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__stddev); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "GatEngine.pyx":1931
 *     if r.stddev == 0:
 *         # dummy pvalue - if no overlap in expected, pvalue is set to 1.
 *         pvalue = 1.0             # <<<<<<<<<<<<<<
 *     else:
 *         if HAS_SCIPY:
 */
    __pyx_t_2 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_pvalue = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1933
 *         pvalue = 1.0
 *     else:
 *         if HAS_SCIPY:             # <<<<<<<<<<<<<<
 *             pvalue = 1.0 - scipy.stats.norm.cdf( absval, 0, r.stddev )
 *         else:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__HAS_SCIPY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_3) {

      /* "GatEngine.pyx":1934
 *     else:
 *         if HAS_SCIPY:
 *             pvalue = 1.0 - scipy.stats.norm.cdf( absval, 0, r.stddev )             # <<<<<<<<<<<<<<
 *         else:
 *             raise ImportError( "scipy required" )
 */
      __pyx_t_2 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__scipy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stats); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__norm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__cdf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__stddev); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_absval);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_absval);
      __Pyx_GIVEREF(__pyx_v_absval);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Subtract(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_pvalue = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "GatEngine.pyx":1936
 *             pvalue = 1.0 - scipy.stats.norm.cdf( absval, 0, r.stddev )
 *         else:
 *             raise ImportError( "scipy required" )             # <<<<<<<<<<<<<<
 *     return pvalue
 * 
 */
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ImportError, ((PyObject *)__pyx_k_tuple_36), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1937
 *         else:
 *             raise ImportError( "scipy required" )
 *     return pvalue             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_pvalue);
  __pyx_r = __pyx_v_pvalue;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.getNormedPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_absval);
  __Pyx_XDECREF(__pyx_v_pvalue);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17getEmpiricalPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_16getEmpiricalPValue[] = "getEmpiricalPValue(value, r)";
static PyMethodDef __pyx_mdef_9GatEngine_17getEmpiricalPValue = {__Pyx_NAMESTR("getEmpiricalPValue"), (PyCFunction)__pyx_pw_9GatEngine_17getEmpiricalPValue, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_16getEmpiricalPValue)};
static PyObject *__pyx_pw_9GatEngine_17getEmpiricalPValue(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_r = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getEmpiricalPValue (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__value,&__pyx_n_s__r,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__r)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getEmpiricalPValue", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getEmpiricalPValue") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_value = values[0];
    __pyx_v_r = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getEmpiricalPValue", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.getEmpiricalPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_16getEmpiricalPValue(__pyx_self, __pyx_v_value, __pyx_v_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1942
 * ############################################################
 * ############################################################
 * def getEmpiricalPValue( value, r ):             # <<<<<<<<<<<<<<
 *     return r.getEmpiricalPValue( value )
 * 
 */

static PyObject *__pyx_pf_9GatEngine_16getEmpiricalPValue(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value, PyObject *__pyx_v_r) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getEmpiricalPValue", 0);

  /* "GatEngine.pyx":1943
 * ############################################################
 * def getEmpiricalPValue( value, r ):
 *     return r.getEmpiricalPValue( value )             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__getEmpiricalPValue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __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 = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.getEmpiricalPValue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_19updatePValues(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18updatePValues[] = "updatePValues(annotator_results, method='empirical')\nupdate pvalues.\n\n    empirical\n        report pvalues from simulations. Minimum pvalue is \n        1/nsamples\n    norm\n        fit Gaussian to simulated values and compute pvalue from\n        the distribution\n    ";
static PyMethodDef __pyx_mdef_9GatEngine_19updatePValues = {__Pyx_NAMESTR("updatePValues"), (PyCFunction)__pyx_pw_9GatEngine_19updatePValues, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18updatePValues)};
static PyObject *__pyx_pw_9GatEngine_19updatePValues(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_annotator_results = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("updatePValues (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__annotator_results,&__pyx_n_s__method,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_n_s__empirical);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotator_results)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__method);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "updatePValues") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_annotator_results = values[0];
    __pyx_v_method = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("updatePValues", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.updatePValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18updatePValues(__pyx_self, __pyx_v_annotator_results, __pyx_v_method);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1948
 * ############################################################
 * ############################################################
 * def updatePValues( annotator_results, method = "empirical" ):             # <<<<<<<<<<<<<<
 *     '''update pvalues.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18updatePValues(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_annotator_results, PyObject *__pyx_v_method) {
  PyObject *__pyx_v_methodf = NULL;
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("updatePValues", 0);

  /* "GatEngine.pyx":1959
 *     '''
 * 
 *     if method == "norm":             # <<<<<<<<<<<<<<
 *         methodf = getNormedPValue
 *     elif method == "empirical":
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__norm), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1960
 * 
 *     if method == "norm":
 *         methodf = getNormedPValue             # <<<<<<<<<<<<<<
 *     elif method == "empirical":
 *         methodf = getEmpiricalPValue
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__getNormedPValue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_methodf = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }

  /* "GatEngine.pyx":1961
 *     if method == "norm":
 *         methodf = getNormedPValue
 *     elif method == "empirical":             # <<<<<<<<<<<<<<
 *         methodf = getEmpiricalPValue
 *     else:
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__empirical), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1962
 *         methodf = getNormedPValue
 *     elif method == "empirical":
 *         methodf = getEmpiricalPValue             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError( "unknown method '%s'" % method )
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__getEmpiricalPValue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_methodf = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1964
 *         methodf = getEmpiricalPValue
 *     else:
 *         raise ValueError( "unknown method '%s'" % method )             # <<<<<<<<<<<<<<
 * 
 *     for r in annotator_results:
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_37), __pyx_v_method); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "GatEngine.pyx":1966
 *         raise ValueError( "unknown method '%s'" % method )
 * 
 *     for r in annotator_results:             # <<<<<<<<<<<<<<
 *         r.pvalue = methodf( r.observed, r )
 * 
 */
  if (PyList_CheckExact(__pyx_v_annotator_results) || PyTuple_CheckExact(__pyx_v_annotator_results)) {
    __pyx_t_1 = __pyx_v_annotator_results; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_annotator_results); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF(__pyx_v_r);
    __pyx_v_r = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":1967
 * 
 *     for r in annotator_results:
 *         r.pvalue = methodf( r.observed, r )             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__observed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_r);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_r);
    __Pyx_GIVEREF(__pyx_v_r);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_v_methodf, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (PyObject_SetAttr(__pyx_v_r, __pyx_n_s__pvalue, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.updatePValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_methodf);
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_21getQValues(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_20getQValues[] = "getQValues(pvalues, method='storey', **kwargs)\nreturn a list of qvalues for a list of pvalues.";
static PyMethodDef __pyx_mdef_9GatEngine_21getQValues = {__Pyx_NAMESTR("getQValues"), (PyCFunction)__pyx_pw_9GatEngine_21getQValues, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_20getQValues)};
static PyObject *__pyx_pw_9GatEngine_21getQValues(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pvalues = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getQValues (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__pvalues,&__pyx_n_s__method,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_n_s__storey);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pvalues)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__method);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "getQValues") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pvalues = values[0];
    __pyx_v_method = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getQValues", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("GatEngine.getQValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_20getQValues(__pyx_self, __pyx_v_pvalues, __pyx_v_method, __pyx_v_kwargs);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1972
 * ############################################################
 * ############################################################
 * def getQValues( pvalues, method = "storey", **kwargs ):             # <<<<<<<<<<<<<<
 *     '''return a list of qvalues for a list of pvalues.'''
 * 
 */

static PyObject *__pyx_pf_9GatEngine_20getQValues(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pvalues, PyObject *__pyx_v_method, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_fdr = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getQValues", 0);

  /* "GatEngine.pyx":1975
 *     '''return a list of qvalues for a list of pvalues.'''
 * 
 *     if method == "storey":             # <<<<<<<<<<<<<<
 *         try:
 *             fdr = gat.Stats.computeQValues( pvalues,
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__storey), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "GatEngine.pyx":1976
 * 
 *     if method == "storey":
 *         try:             # <<<<<<<<<<<<<<
 *             fdr = gat.Stats.computeQValues( pvalues,
 *                                             vlambda = kwargs.get( "vlambda", numpy.arange( 0,0.95,0.05) ),
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {

        /* "GatEngine.pyx":1977
 *     if method == "storey":
 *         try:
 *             fdr = gat.Stats.computeQValues( pvalues,             # <<<<<<<<<<<<<<
 *                                             vlambda = kwargs.get( "vlambda", numpy.arange( 0,0.95,0.05) ),
 *                                             pi0_method = kwargs.get( "pi0_method", "smoother") )
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__gat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__Stats); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__computeQValues); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_v_pvalues);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_pvalues);
        __Pyx_GIVEREF(__pyx_v_pvalues);
        __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_7));

        /* "GatEngine.pyx":1978
 *         try:
 *             fdr = gat.Stats.computeQValues( pvalues,
 *                                             vlambda = kwargs.get( "vlambda", numpy.arange( 0,0.95,0.05) ),             # <<<<<<<<<<<<<<
 *                                             pi0_method = kwargs.get( "pi0_method", "smoother") )
 *         except ValueError, msg:
 */
        __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__arange); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyFloat_FromDouble(0.95); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = PyFloat_FromDouble(0.05); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_t_8 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
        __pyx_t_11 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__vlambda), __pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__vlambda), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "GatEngine.pyx":1979
 *             fdr = gat.Stats.computeQValues( pvalues,
 *                                             vlambda = kwargs.get( "vlambda", numpy.arange( 0,0.95,0.05) ),
 *                                             pi0_method = kwargs.get( "pi0_method", "smoother") )             # <<<<<<<<<<<<<<
 *         except ValueError, msg:
 *             E.warn( "qvalue computation failed: %s" % msg )
 */
        __pyx_t_11 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__pi0_method), ((PyObject *)__pyx_n_s__smoother)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_11);
        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__pi0_method), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        __pyx_v_fdr = __pyx_t_11;
        __pyx_t_11 = 0;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "GatEngine.pyx":1980
 *                                             vlambda = kwargs.get( "vlambda", numpy.arange( 0,0.95,0.05) ),
 *                                             pi0_method = kwargs.get( "pi0_method", "smoother") )
 *         except ValueError, msg:             # <<<<<<<<<<<<<<
 *             E.warn( "qvalue computation failed: %s" % msg )
 *             return [1.0] * len(pvalues)
 */
      __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_12) {
        __Pyx_AddTraceback("GatEngine.getQValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_7, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __pyx_v_msg = __pyx_t_7;

        /* "GatEngine.pyx":1981
 *                                             pi0_method = kwargs.get( "pi0_method", "smoother") )
 *         except ValueError, msg:
 *             E.warn( "qvalue computation failed: %s" % msg )             # <<<<<<<<<<<<<<
 *             return [1.0] * len(pvalues)
 * 
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__warn); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_38), __pyx_v_msg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_1));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "GatEngine.pyx":1982
 *         except ValueError, msg:
 *             E.warn( "qvalue computation failed: %s" % msg )
 *             return [1.0] * len(pvalues)             # <<<<<<<<<<<<<<
 * 
 *         return fdr.qvalues
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = PyObject_Length(__pyx_v_pvalues); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __pyx_t_9 = PyList_New(1 * ((__pyx_t_13<0) ? 0:__pyx_t_13)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < __pyx_t_13; __pyx_temp++) {
            __Pyx_INCREF(__pyx_t_1);
            PyList_SET_ITEM(__pyx_t_9, __pyx_temp, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
          }
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_r = ((PyObject *)__pyx_t_9);
        __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L7_except_return;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L5_exception_handled;
      }
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L7_except_return:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L0;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L11_try_end:;
    }

    /* "GatEngine.pyx":1984
 *             return [1.0] * len(pvalues)
 * 
 *         return fdr.qvalues             # <<<<<<<<<<<<<<
 *     else:
 *         return gat.Stats.adjustPValues( pvalues, method = method )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_fdr, __pyx_n_s__qvalues); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":1986
 *         return fdr.qvalues
 *     else:
 *         return gat.Stats.adjustPValues( pvalues, method = method )             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__gat); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__Stats); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__adjustPValues); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_pvalues);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_pvalues);
    __Pyx_GIVEREF(__pyx_v_pvalues);
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_11));
    if (PyDict_SetItem(__pyx_t_11, ((PyObject *)__pyx_n_s__method), __pyx_v_method) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
    __pyx_r = __pyx_t_9;
    __pyx_t_9 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("GatEngine.getQValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fdr);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_23updateQValues(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_22updateQValues[] = "updateQValues(annotator_results, method='storey', **kwargs)\nupdate qvalues in annotator results\n\n    storey\n        qvalue from the method by Storey et al.\n    ";
static PyMethodDef __pyx_mdef_9GatEngine_23updateQValues = {__Pyx_NAMESTR("updateQValues"), (PyCFunction)__pyx_pw_9GatEngine_23updateQValues, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_22updateQValues)};
static PyObject *__pyx_pw_9GatEngine_23updateQValues(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_annotator_results = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("updateQValues (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__annotator_results,&__pyx_n_s__method,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_n_s__storey);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotator_results)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__method);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "updateQValues") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_annotator_results = values[0];
    __pyx_v_method = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("updateQValues", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("GatEngine.updateQValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_22updateQValues(__pyx_self, __pyx_v_annotator_results, __pyx_v_method, __pyx_v_kwargs);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":1991
 * ############################################################
 * ############################################################
 * def updateQValues( annotator_results, method = "storey", **kwargs ):             # <<<<<<<<<<<<<<
 *     '''update qvalues in annotator results
 * 
 */

static PyObject *__pyx_pf_9GatEngine_22updateQValues(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_annotator_results, PyObject *__pyx_v_method, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_pvalues = NULL;
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_v_qvalue = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("updateQValues", 0);

  /* "GatEngine.pyx":1998
 *     '''
 * 
 *     pvalues = [ r.pvalue for r in annotator_results ]             # <<<<<<<<<<<<<<
 * 
 *     for r, qvalue in zip( annotator_results, getQValues( pvalues, method, **kwargs )):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyList_CheckExact(__pyx_v_annotator_results) || PyTuple_CheckExact(__pyx_v_annotator_results)) {
    __pyx_t_2 = __pyx_v_annotator_results; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_annotator_results); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF(__pyx_v_r);
    __pyx_v_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__pvalue); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = ((PyObject *)__pyx_t_1);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_pvalues = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":2000
 *     pvalues = [ r.pvalue for r in annotator_results ]
 * 
 *     for r, qvalue in zip( annotator_results, getQValues( pvalues, method, **kwargs )):             # <<<<<<<<<<<<<<
 *         r.qvalue = qvalue
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__getQValues); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_pvalues));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_pvalues));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_pvalues));
  __Pyx_INCREF(__pyx_v_method);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_method);
  __Pyx_GIVEREF(__pyx_v_method);
  __pyx_t_5 = ((PyObject *)__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_annotator_results);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_annotator_results);
  __Pyx_GIVEREF(__pyx_v_annotator_results);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_builtin_zip, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = Py_TYPE(__pyx_t_5)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_5)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_5)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_6 = __pyx_t_4(__pyx_t_5);
      if (unlikely(!__pyx_t_6)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L8_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_r);
    __pyx_v_r = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_qvalue);
    __pyx_v_qvalue = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2001
 * 
 *     for r, qvalue in zip( annotator_results, getQValues( pvalues, method, **kwargs )):
 *         r.qvalue = qvalue             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
    if (PyObject_SetAttr(__pyx_v_r, __pyx_n_s__qvalue, __pyx_v_qvalue) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.updateQValues", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pvalues);
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_qvalue);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_22UnconditionalWorkspace_1__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_22UnconditionalWorkspace___call__[] = "UnconditionalWorkspace.__call__(self, segments, annotations, workspace)";
static PyMethodDef __pyx_mdef_9GatEngine_22UnconditionalWorkspace_1__call__ = {__Pyx_NAMESTR("__call__"), (PyCFunction)__pyx_pw_9GatEngine_22UnconditionalWorkspace_1__call__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_22UnconditionalWorkspace___call__)};
static PyObject *__pyx_pw_9GatEngine_22UnconditionalWorkspace_1__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_segments = values[1];
    __pyx_v_annotations = values[2];
    __pyx_v_workspace = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.UnconditionalWorkspace.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_22UnconditionalWorkspace___call__(__pyx_self, __pyx_v_self, __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2015
 *     is_conditional = False
 * 
 *     def __call__(self, segments, annotations, workspace):             # <<<<<<<<<<<<<<
 *         return segments, annotations, workspace
 * 
 */

static PyObject *__pyx_pf_9GatEngine_22UnconditionalWorkspace___call__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":2016
 * 
 *     def __call__(self, segments, annotations, workspace):
 *         return segments, annotations, workspace             # <<<<<<<<<<<<<<
 * 
 *     def filter( self, segments, annotations, workspace ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __Pyx_INCREF(__pyx_v_workspace);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_workspace);
  __Pyx_GIVEREF(__pyx_v_workspace);
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.UnconditionalWorkspace.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_22UnconditionalWorkspace_3filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_22UnconditionalWorkspace_2filter[] = "UnconditionalWorkspace.filter(self, segments, annotations, workspace)\nrestrict annotations and segments to workspace.\n\n        This speeds up computations.\n        \n        returns filtered segments, filtered annotations, workspace\n        ";
static PyMethodDef __pyx_mdef_9GatEngine_22UnconditionalWorkspace_3filter = {__Pyx_NAMESTR("filter"), (PyCFunction)__pyx_pw_9GatEngine_22UnconditionalWorkspace_3filter, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_22UnconditionalWorkspace_2filter)};
static PyObject *__pyx_pw_9GatEngine_22UnconditionalWorkspace_3filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("filter", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_segments = values[1];
    __pyx_v_annotations = values[2];
    __pyx_v_workspace = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("filter", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.UnconditionalWorkspace.filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_22UnconditionalWorkspace_2filter(__pyx_self, __pyx_v_self, __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2018
 *         return segments, annotations, workspace
 * 
 *     def filter( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 *         '''restrict annotations and segments to workspace.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_22UnconditionalWorkspace_2filter(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace) {
  PyObject *__pyx_v_temp_annotations = NULL;
  PyObject *__pyx_v_temp_segments = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("filter", 0);

  /* "GatEngine.pyx":2026
 *         '''
 * 
 *         if annotations:             # <<<<<<<<<<<<<<
 *             temp_annotations = annotations.clone()
 *             temp_annotations.filter( workspace )
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_annotations); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2027
 * 
 *         if annotations:
 *             temp_annotations = annotations.clone()             # <<<<<<<<<<<<<<
 *             temp_annotations.filter( workspace )
 *         else:
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_annotations, __pyx_n_s__clone); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_temp_annotations = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":2028
 *         if annotations:
 *             temp_annotations = annotations.clone()
 *             temp_annotations.filter( workspace )             # <<<<<<<<<<<<<<
 *         else:
 *             temp_annotations = None
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_temp_annotations, __pyx_n_s__filter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_workspace);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_workspace);
    __Pyx_GIVEREF(__pyx_v_workspace);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":2030
 *             temp_annotations.filter( workspace )
 *         else:
 *             temp_annotations = None             # <<<<<<<<<<<<<<
 * 
 *         if segments:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_temp_annotations = Py_None;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2032
 *             temp_annotations = None
 * 
 *         if segments:             # <<<<<<<<<<<<<<
 *             temp_segments = segments.clone()
 *             temp_segments.filter( workspace )
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_segments); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2033
 * 
 *         if segments:
 *             temp_segments = segments.clone()             # <<<<<<<<<<<<<<
 *             temp_segments.filter( workspace )
 *         else:
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_segments, __pyx_n_s__clone); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_temp_segments = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2034
 *         if segments:
 *             temp_segments = segments.clone()
 *             temp_segments.filter( workspace )             # <<<<<<<<<<<<<<
 *         else:
 *             temp_segments = None
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_temp_segments, __pyx_n_s__filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_workspace);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_workspace);
    __Pyx_GIVEREF(__pyx_v_workspace);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "GatEngine.pyx":2036
 *             temp_segments.filter( workspace )
 *         else:
 *             temp_segments = None             # <<<<<<<<<<<<<<
 * 
 *         return temp_segments, temp_annotations, workspace
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_temp_segments = Py_None;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":2038
 *             temp_segments = None
 * 
 *         return temp_segments, temp_annotations, workspace             # <<<<<<<<<<<<<<
 * 
 * class ConditionalWorkspaceCooccurance( UnconditionalWorkspace):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_temp_segments);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_temp_segments);
  __Pyx_GIVEREF(__pyx_v_temp_segments);
  __Pyx_INCREF(__pyx_v_temp_annotations);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_temp_annotations);
  __Pyx_GIVEREF(__pyx_v_temp_annotations);
  __Pyx_INCREF(__pyx_v_workspace);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_workspace);
  __Pyx_GIVEREF(__pyx_v_workspace);
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.UnconditionalWorkspace.filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_temp_annotations);
  __Pyx_XDECREF(__pyx_v_temp_segments);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_31ConditionalWorkspaceCooccurance_1__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_31ConditionalWorkspaceCooccurance___call__[] = "ConditionalWorkspaceCooccurance.__call__(self, segments, annotations, workspace)";
static PyMethodDef __pyx_mdef_9GatEngine_31ConditionalWorkspaceCooccurance_1__call__ = {__Pyx_NAMESTR("__call__"), (PyCFunction)__pyx_pw_9GatEngine_31ConditionalWorkspaceCooccurance_1__call__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_31ConditionalWorkspaceCooccurance___call__)};
static PyObject *__pyx_pw_9GatEngine_31ConditionalWorkspaceCooccurance_1__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_segments = values[1];
    __pyx_v_annotations = values[2];
    __pyx_v_workspace = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceCooccurance.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_31ConditionalWorkspaceCooccurance___call__(__pyx_self, __pyx_v_self, __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2049
 *     is_conditional = True
 * 
 *     def __call__( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 * 
 *         # restrict workspace to those segments that contain both annotations and segments
 */

static PyObject *__pyx_pf_9GatEngine_31ConditionalWorkspaceCooccurance___call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace) {
  PyObject *__pyx_v_temp_workspace = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":2052
 * 
 *         # restrict workspace to those segments that contain both annotations and segments
 *         temp_workspace = workspace.clone()             # <<<<<<<<<<<<<<
 *         temp_workspace.filter( annotations )
 *         temp_workspace.filter( segments )
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_workspace, __pyx_n_s__clone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_temp_workspace = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":2053
 *         # restrict workspace to those segments that contain both annotations and segments
 *         temp_workspace = workspace.clone()
 *         temp_workspace.filter( annotations )             # <<<<<<<<<<<<<<
 *         temp_workspace.filter( segments )
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_temp_workspace, __pyx_n_s__filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2054
 *         temp_workspace = workspace.clone()
 *         temp_workspace.filter( annotations )
 *         temp_workspace.filter( segments )             # <<<<<<<<<<<<<<
 * 
 *         return self.filter( segments, annotations, temp_workspace )
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_temp_workspace, __pyx_n_s__filter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2056
 *         temp_workspace.filter( segments )
 * 
 *         return self.filter( segments, annotations, temp_workspace )             # <<<<<<<<<<<<<<
 * 
 * class ConditionalWorkspaceCentered( UnconditionalWorkspace ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __Pyx_INCREF(__pyx_v_temp_workspace);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_temp_workspace);
  __Pyx_GIVEREF(__pyx_v_temp_workspace);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceCooccurance.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_temp_workspace);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_28ConditionalWorkspaceCentered_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_28ConditionalWorkspaceCentered___init__[] = "ConditionalWorkspaceCentered.__init__(self, extension=None, expansion=None)";
static PyMethodDef __pyx_mdef_9GatEngine_28ConditionalWorkspaceCentered_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_9GatEngine_28ConditionalWorkspaceCentered_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_28ConditionalWorkspaceCentered___init__)};
static PyObject *__pyx_pw_9GatEngine_28ConditionalWorkspaceCentered_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_extension = 0;
  PyObject *__pyx_v_expansion = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__extension,&__pyx_n_s__expansion,0};
    PyObject* values[3] = {0,0,0};

    /* "GatEngine.pyx":2063
 *     is_conditional = True
 * 
 *     def __init__( self, extension = None, expansion = None ):             # <<<<<<<<<<<<<<
 *         self.extension = extension
 *         self.expansion = expansion
 */
    values[1] = ((PyObject *)((PyObject *)Py_None));
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__extension);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__expansion);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_extension = values[1];
    __pyx_v_expansion = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceCentered.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_28ConditionalWorkspaceCentered___init__(__pyx_self, __pyx_v_self, __pyx_v_extension, __pyx_v_expansion);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_28ConditionalWorkspaceCentered___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_extension, PyObject *__pyx_v_expansion) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2064
 * 
 *     def __init__( self, extension = None, expansion = None ):
 *         self.extension = extension             # <<<<<<<<<<<<<<
 *         self.expansion = expansion
 *         if self.extension == self.expansion == None:
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__extension, __pyx_v_extension) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2065
 *     def __init__( self, extension = None, expansion = None ):
 *         self.extension = extension
 *         self.expansion = expansion             # <<<<<<<<<<<<<<
 *         if self.extension == self.expansion == None:
 *             raise ValueError( "need to specify either expansion or extension" )
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__expansion, __pyx_v_expansion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2066
 *         self.extension = extension
 *         self.expansion = expansion
 *         if self.extension == self.expansion == None:             # <<<<<<<<<<<<<<
 *             raise ValueError( "need to specify either expansion or extension" )
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__extension); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__expansion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "GatEngine.pyx":2067
 *         self.expansion = expansion
 *         if self.extension == self.expansion == None:
 *             raise ValueError( "need to specify either expansion or extension" )             # <<<<<<<<<<<<<<
 * 
 *     def __call__( self, segments, annotations, workspace ):
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceCentered.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_28ConditionalWorkspaceCentered_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_28ConditionalWorkspaceCentered_2__call__[] = "ConditionalWorkspaceCentered.__call__(self, segments, annotations, workspace)";
static PyMethodDef __pyx_mdef_9GatEngine_28ConditionalWorkspaceCentered_3__call__ = {__Pyx_NAMESTR("__call__"), (PyCFunction)__pyx_pw_9GatEngine_28ConditionalWorkspaceCentered_3__call__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_28ConditionalWorkspaceCentered_2__call__)};
static PyObject *__pyx_pw_9GatEngine_28ConditionalWorkspaceCentered_3__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_segments = values[1];
    __pyx_v_annotations = values[2];
    __pyx_v_workspace = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceCentered.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_28ConditionalWorkspaceCentered_2__call__(__pyx_self, __pyx_v_self, __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2069
 *             raise ValueError( "need to specify either expansion or extension" )
 * 
 *     def __call__( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 * 
 *         # build workspace from annotations
 */

static PyObject *__pyx_pf_9GatEngine_28ConditionalWorkspaceCentered_2__call__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace) {
  PyObject *__pyx_v_temp_workspace = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "GatEngine.pyx":2072
 * 
 *         # build workspace from annotations
 *         temp_workspace = self.getCenter( segments, annotations ).clone()             # <<<<<<<<<<<<<<
 *         if self.extension != None:
 *             temp_workspace.extend( self.extension )
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getCenter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __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 = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__clone); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_temp_workspace = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2073
 *         # build workspace from annotations
 *         temp_workspace = self.getCenter( segments, annotations ).clone()
 *         if self.extension != None:             # <<<<<<<<<<<<<<
 *             temp_workspace.extend( self.extension )
 *         else:
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__extension); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "GatEngine.pyx":2074
 *         temp_workspace = self.getCenter( segments, annotations ).clone()
 *         if self.extension != None:
 *             temp_workspace.extend( self.extension )             # <<<<<<<<<<<<<<
 *         else:
 *             temp_workspace.expand( self.expansion )
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_temp_workspace, __pyx_n_s__extend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__extension); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":2076
 *             temp_workspace.extend( self.extension )
 *         else:
 *             temp_workspace.expand( self.expansion )             # <<<<<<<<<<<<<<
 *         temp_workspace.normalize()
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_temp_workspace, __pyx_n_s__expand); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__expansion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2077
 *         else:
 *             temp_workspace.expand( self.expansion )
 *         temp_workspace.normalize()             # <<<<<<<<<<<<<<
 * 
 *         # intersect with global workspace
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_temp_workspace, __pyx_n_s__normalize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2080
 * 
 *         # intersect with global workspace
 *         temp_workspace.intersect( workspace )             # <<<<<<<<<<<<<<
 * 
 *         return self.filter( segments, annotations, temp_workspace )
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_temp_workspace, __pyx_n_s__intersect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_workspace);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_workspace);
  __Pyx_GIVEREF(__pyx_v_workspace);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2082
 *         temp_workspace.intersect( workspace )
 * 
 *         return self.filter( segments, annotations, temp_workspace )             # <<<<<<<<<<<<<<
 * 
 * class ConditionalWorkspaceAnnotationCentered( ConditionalWorkspaceCentered ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__filter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_segments);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __Pyx_INCREF(__pyx_v_annotations);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_annotations);
  __Pyx_GIVEREF(__pyx_v_annotations);
  __Pyx_INCREF(__pyx_v_temp_workspace);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_temp_workspace);
  __Pyx_GIVEREF(__pyx_v_temp_workspace);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceCentered.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_temp_workspace);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_38ConditionalWorkspaceAnnotationCentered_1getCenter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_38ConditionalWorkspaceAnnotationCentered_getCenter[] = "ConditionalWorkspaceAnnotationCentered.getCenter(self, segments, annotations)";
static PyMethodDef __pyx_mdef_9GatEngine_38ConditionalWorkspaceAnnotationCentered_1getCenter = {__Pyx_NAMESTR("getCenter"), (PyCFunction)__pyx_pw_9GatEngine_38ConditionalWorkspaceAnnotationCentered_1getCenter, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_38ConditionalWorkspaceAnnotationCentered_getCenter)};
static PyObject *__pyx_pw_9GatEngine_38ConditionalWorkspaceAnnotationCentered_1getCenter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCenter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__segments,&__pyx_n_s__annotations,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getCenter", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getCenter", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getCenter") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_segments = values[1];
    __pyx_v_annotations = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getCenter", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceAnnotationCentered.getCenter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_38ConditionalWorkspaceAnnotationCentered_getCenter(__pyx_self, __pyx_v_self, __pyx_v_segments, __pyx_v_annotations);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2089
 *     workspace is derived from the locations of the annotations.
 *     '''
 *     def getCenter( self, segments, annotations):             # <<<<<<<<<<<<<<
 *         return annotations
 * 
 */

static PyObject *__pyx_pf_9GatEngine_38ConditionalWorkspaceAnnotationCentered_getCenter(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCenter", 0);

  /* "GatEngine.pyx":2090
 *     '''
 *     def getCenter( self, segments, annotations):
 *         return annotations             # <<<<<<<<<<<<<<
 * 
 * class ConditionalWorkspaceSegmentCentered( ConditionalWorkspaceCentered ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_annotations);
  __pyx_r = __pyx_v_annotations;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_35ConditionalWorkspaceSegmentCentered_1getCenter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_35ConditionalWorkspaceSegmentCentered_getCenter[] = "ConditionalWorkspaceSegmentCentered.getCenter(self, segments, annotations)";
static PyMethodDef __pyx_mdef_9GatEngine_35ConditionalWorkspaceSegmentCentered_1getCenter = {__Pyx_NAMESTR("getCenter"), (PyCFunction)__pyx_pw_9GatEngine_35ConditionalWorkspaceSegmentCentered_1getCenter, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_35ConditionalWorkspaceSegmentCentered_getCenter)};
static PyObject *__pyx_pw_9GatEngine_35ConditionalWorkspaceSegmentCentered_1getCenter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_segments = 0;
  CYTHON_UNUSED PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCenter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__segments,&__pyx_n_s__annotations,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getCenter", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("getCenter", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getCenter") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_segments = values[1];
    __pyx_v_annotations = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getCenter", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.ConditionalWorkspaceSegmentCentered.getCenter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_35ConditionalWorkspaceSegmentCentered_getCenter(__pyx_self, __pyx_v_self, __pyx_v_segments, __pyx_v_annotations);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2099
 *     # workspace needs to be computed on a per-segment basis
 *     is_conditional = False
 *     def getCenter( self, segments, annotations):             # <<<<<<<<<<<<<<
 *         return segments
 * 
 */

static PyObject *__pyx_pf_9GatEngine_35ConditionalWorkspaceSegmentCentered_getCenter(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_segments, CYTHON_UNUSED PyObject *__pyx_v_annotations) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCenter", 0);

  /* "GatEngine.pyx":2100
 *     is_conditional = False
 *     def getCenter( self, segments, annotations):
 *         return segments             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_segments);
  __pyx_r = __pyx_v_segments;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_25_append(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_24_append[] = "_append(counts, x, y, z)";
static PyMethodDef __pyx_mdef_9GatEngine_25_append = {__Pyx_NAMESTR("_append"), (PyCFunction)__pyx_pw_9GatEngine_25_append, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_24_append)};
static PyObject *__pyx_pw_9GatEngine_25_append(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_counts = 0;
  CYTHON_UNUSED PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  PyObject *__pyx_v_z = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_append (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__counts,&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__counts)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_append", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_append", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_append", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_append") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_counts = values[0];
    __pyx_v_x = values[1];
    __pyx_v_y = values[2];
    __pyx_v_z = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_append", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine._append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_24_append(__pyx_self, __pyx_v_counts, __pyx_v_x, __pyx_v_y, __pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2107
 * ## compute counts
 * ############################################################
 * def _append( counts, x,y,z): counts[y].append(z)             # <<<<<<<<<<<<<<
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )
 * def _defdictfloat(): return collections.defaultdict(float)
 */

static PyObject *__pyx_pf_9GatEngine_24_append(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_counts, CYTHON_UNUSED PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_z) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_append", 0);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_counts, __pyx_v_y); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_z); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine._append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_27_set(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_26_set[] = "_set(counts, x, y, z)";
static PyMethodDef __pyx_mdef_9GatEngine_27_set = {__Pyx_NAMESTR("_set"), (PyCFunction)__pyx_pw_9GatEngine_27_set, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_26_set)};
static PyObject *__pyx_pw_9GatEngine_27_set(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_counts = 0;
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  PyObject *__pyx_v_z = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__counts,&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__counts)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_set", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_set") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_counts = values[0];
    __pyx_v_x = values[1];
    __pyx_v_y = values[2];
    __pyx_v_z = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_set", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine._set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_26_set(__pyx_self, __pyx_v_counts, __pyx_v_x, __pyx_v_y, __pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2108
 * ############################################################
 * def _append( counts, x,y,z): counts[y].append(z)
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )             # <<<<<<<<<<<<<<
 * def _defdictfloat(): return collections.defaultdict(float)
 * 
 */

static PyObject *__pyx_pf_9GatEngine_26_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_counts, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_z) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_set", 0);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_counts, __pyx_v_x); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____setitem__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_y);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_y);
  __Pyx_GIVEREF(__pyx_v_y);
  __Pyx_INCREF(__pyx_v_z);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_z);
  __Pyx_GIVEREF(__pyx_v_z);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine._set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_29_defdictfloat(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_28_defdictfloat[] = "_defdictfloat()";
static PyMethodDef __pyx_mdef_9GatEngine_29_defdictfloat = {__Pyx_NAMESTR("_defdictfloat"), (PyCFunction)__pyx_pw_9GatEngine_29_defdictfloat, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_28_defdictfloat)};
static PyObject *__pyx_pw_9GatEngine_29_defdictfloat(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_defdictfloat (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_28_defdictfloat(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2109
 * def _append( counts, x,y,z): counts[y].append(z)
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )
 * def _defdictfloat(): return collections.defaultdict(float)             # <<<<<<<<<<<<<<
 * 
 * def computeCounts( counter,
 */

static PyObject *__pyx_pf_9GatEngine_28_defdictfloat(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_defdictfloat", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyFloat_Type))));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)(&PyFloat_Type))));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyFloat_Type))));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine._defdictfloat", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_31computeCounts(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_30computeCounts[] = "computeCounts(counter, aggregator, segments, annotations, workspace, workspace_generator, append=False)\ncollect counts from *counter* between all combinations of *segments* and *annotations*.\n\n    *aggregator* determines how values are combined across isochores.\n\n    If *append* is set, values for each track in *segments* are appended to a list for\n    each track in *annotations*. This is useful for samples.  Otherwise, a nested dictionary is returned.\n\n    ";
static PyMethodDef __pyx_mdef_9GatEngine_31computeCounts = {__Pyx_NAMESTR("computeCounts"), (PyCFunction)__pyx_pw_9GatEngine_31computeCounts, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_30computeCounts)};
static PyObject *__pyx_pw_9GatEngine_31computeCounts(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_counter = 0;
  PyObject *__pyx_v_aggregator = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_annotations = 0;
  PyObject *__pyx_v_workspace = 0;
  PyObject *__pyx_v_workspace_generator = 0;
  PyObject *__pyx_v_append = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("computeCounts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__counter,&__pyx_n_s__aggregator,&__pyx_n_s__segments,&__pyx_n_s__annotations,&__pyx_n_s__workspace,&__pyx_n_s__workspace_generator,&__pyx_n_s__append,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[6] = __pyx_k_41;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__counter)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__aggregator)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("computeCounts", 0, 6, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("computeCounts", 0, 6, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__annotations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("computeCounts", 0, 6, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("computeCounts", 0, 6, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__workspace_generator)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("computeCounts", 0, 6, 7, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__append);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "computeCounts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_counter = values[0];
    __pyx_v_aggregator = values[1];
    __pyx_v_segments = values[2];
    __pyx_v_annotations = values[3];
    __pyx_v_workspace = values[4];
    __pyx_v_workspace_generator = values[5];
    __pyx_v_append = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("computeCounts", 0, 6, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.computeCounts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_30computeCounts(__pyx_self, __pyx_v_counter, __pyx_v_aggregator, __pyx_v_segments, __pyx_v_annotations, __pyx_v_workspace, __pyx_v_workspace_generator, __pyx_v_append);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2111
 * def _defdictfloat(): return collections.defaultdict(float)
 * 
 * def computeCounts( counter,             # <<<<<<<<<<<<<<
 *                    aggregator,
 *                    segments,
 */

static PyObject *__pyx_pf_9GatEngine_30computeCounts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_counter, PyObject *__pyx_v_aggregator, PyObject *__pyx_v_segments, PyObject *__pyx_v_annotations, PyObject *__pyx_v_workspace, PyObject *__pyx_v_workspace_generator, PyObject *__pyx_v_append) {
  PyObject *__pyx_v_counts = NULL;
  PyObject *__pyx_v_f = NULL;
  PyObject *__pyx_v_isochores = NULL;
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_segs = NULL;
  PyObject *__pyx_v_annotation = NULL;
  PyObject *__pyx_v_annos = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_temp_segs = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_temp_annos = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_temp_workspace = NULL;
  PyObject *__pyx_v_vals = NULL;
  PyObject *__pyx_v_isochore = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  Py_ssize_t __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("computeCounts", 0);

  /* "GatEngine.pyx":2127
 *     '''
 * 
 *     if append:             # <<<<<<<<<<<<<<
 *         counts = collections.defaultdict( list )
 *         f = _append
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_append); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2128
 * 
 *     if append:
 *         counts = collections.defaultdict( list )             # <<<<<<<<<<<<<<
 *         f = _append
 *     else:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)((PyObject*)(&PyList_Type))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)(&PyList_Type))));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyList_Type))));
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_v_counts = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "GatEngine.pyx":2129
 *     if append:
 *         counts = collections.defaultdict( list )
 *         f = _append             # <<<<<<<<<<<<<<
 *     else:
 *         counts = collections.defaultdict( _defdictfloat )
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___append); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_f = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":2131
 *         f = _append
 *     else:
 *         counts = collections.defaultdict( _defdictfloat )             # <<<<<<<<<<<<<<
 *         f = _set
 * 
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___defdictfloat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __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 = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_v_counts = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "GatEngine.pyx":2132
 *     else:
 *         counts = collections.defaultdict( _defdictfloat )
 *         f = _set             # <<<<<<<<<<<<<<
 * 
 *     isochores = workspace.keys()
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_f = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2134
 *         f = _set
 * 
 *     isochores = workspace.keys()             # <<<<<<<<<<<<<<
 * 
 *     # collect counts per isochore and aggregate these
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_workspace, __pyx_n_s__keys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_isochores = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2137
 * 
 *     # collect counts per isochore and aggregate these
 *     for track in segments.tracks:             # <<<<<<<<<<<<<<
 *         segs = segments[track]
 * 
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_segments, __pyx_n_s__tracks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":2138
 *     # collect counts per isochore and aggregate these
 *     for track in segments.tracks:
 *         segs = segments[track]             # <<<<<<<<<<<<<<
 * 
 *         for annotation in annotations.tracks:
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_segments, __pyx_v_track); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF(__pyx_v_segs);
    __pyx_v_segs = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "GatEngine.pyx":2140
 *         segs = segments[track]
 * 
 *         for annotation in annotations.tracks:             # <<<<<<<<<<<<<<
 *             annos = annotations[annotation]
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_annotations, __pyx_n_s__tracks); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_3 = __pyx_t_8(__pyx_t_2);
        if (unlikely(!__pyx_t_3)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF(__pyx_v_annotation);
      __pyx_v_annotation = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":2141
 * 
 *         for annotation in annotations.tracks:
 *             annos = annotations[annotation]             # <<<<<<<<<<<<<<
 * 
 *             temp_segs, temp_annos, temp_workspace = workspace_generator( segs, annos, workspace )
 */
      __pyx_t_3 = PyObject_GetItem(__pyx_v_annotations, __pyx_v_annotation); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_v_annos);
      __pyx_v_annos = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":2143
 *             annos = annotations[annotation]
 * 
 *             temp_segs, temp_annos, temp_workspace = workspace_generator( segs, annos, workspace )             # <<<<<<<<<<<<<<
 *             vals = [ counter( segs[isochore], annos[isochore], workspace[isochore] ) for isochore in isochores ]
 *             f(counts, track, annotation, aggregator(vals) )
 */
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_segs);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_segs);
      __Pyx_GIVEREF(__pyx_v_segs);
      __Pyx_INCREF(__pyx_v_annos);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_annos);
      __Pyx_GIVEREF(__pyx_v_annos);
      __Pyx_INCREF(__pyx_v_workspace);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_workspace);
      __Pyx_GIVEREF(__pyx_v_workspace);
      __pyx_t_9 = PyObject_Call(__pyx_v_workspace_generator, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
        PyObject* sequence = __pyx_t_9;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_12 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        index = 2; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_temp_segs);
      __pyx_v_temp_segs = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_v_temp_annos);
      __pyx_v_temp_annos = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_v_temp_workspace);
      __pyx_v_temp_workspace = __pyx_t_11;
      __pyx_t_11 = 0;

      /* "GatEngine.pyx":2144
 * 
 *             temp_segs, temp_annos, temp_workspace = workspace_generator( segs, annos, workspace )
 *             vals = [ counter( segs[isochore], annos[isochore], workspace[isochore] ) for isochore in isochores ]             # <<<<<<<<<<<<<<
 *             f(counts, track, annotation, aggregator(vals) )
 * 
 */
      __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (PyList_CheckExact(__pyx_v_isochores) || PyTuple_CheckExact(__pyx_v_isochores)) {
        __pyx_t_11 = __pyx_v_isochores; __Pyx_INCREF(__pyx_t_11); __pyx_t_14 = 0;
        __pyx_t_15 = NULL;
      } else {
        __pyx_t_14 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_isochores); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
      }
      for (;;) {
        if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_11)) {
          if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_11)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_10 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_14); __Pyx_INCREF(__pyx_t_10); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_11, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_11)) {
          if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_14); __Pyx_INCREF(__pyx_t_10); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_11, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          __pyx_t_10 = __pyx_t_15(__pyx_t_11);
          if (unlikely(!__pyx_t_10)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_XDECREF(__pyx_v_isochore);
        __pyx_v_isochore = __pyx_t_10;
        __pyx_t_10 = 0;
        __pyx_t_10 = PyObject_GetItem(__pyx_v_segs, __pyx_v_isochore); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_3 = PyObject_GetItem(__pyx_v_annos, __pyx_v_isochore); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_workspace, __pyx_v_isochore); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_16 = PyTuple_New(3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_16, 2, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        __pyx_t_10 = 0;
        __pyx_t_3 = 0;
        __pyx_t_12 = 0;
        __pyx_t_12 = PyObject_Call(__pyx_v_counter, ((PyObject *)__pyx_t_16), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(((PyObject *)__pyx_t_16)); __pyx_t_16 = 0;
        if (unlikely(__Pyx_PyList_Append(__pyx_t_9, (PyObject*)__pyx_t_12))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = ((PyObject *)__pyx_t_9);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_vals));
      __pyx_v_vals = ((PyObject*)__pyx_t_11);
      __pyx_t_11 = 0;

      /* "GatEngine.pyx":2145
 *             temp_segs, temp_annos, temp_workspace = workspace_generator( segs, annos, workspace )
 *             vals = [ counter( segs[isochore], annos[isochore], workspace[isochore] ) for isochore in isochores ]
 *             f(counts, track, annotation, aggregator(vals) )             # <<<<<<<<<<<<<<
 * 
 *     return counts
 */
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(((PyObject *)__pyx_v_vals));
      PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_v_vals));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_vals));
      __pyx_t_9 = PyObject_Call(__pyx_v_aggregator, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_counts);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_counts);
      __Pyx_GIVEREF(__pyx_v_counts);
      __Pyx_INCREF(__pyx_v_track);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_track);
      __Pyx_GIVEREF(__pyx_v_track);
      __Pyx_INCREF(__pyx_v_annotation);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_annotation);
      __Pyx_GIVEREF(__pyx_v_annotation);
      PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_v_f, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "GatEngine.pyx":2147
 *             f(counts, track, annotation, aggregator(vals) )
 * 
 *     return counts             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_counts);
  __pyx_r = __pyx_v_counts;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("GatEngine.computeCounts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_f);
  __Pyx_XDECREF(__pyx_v_isochores);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XDECREF(__pyx_v_annotation);
  __Pyx_XDECREF(__pyx_v_annos);
  __Pyx_XDECREF(__pyx_v_temp_segs);
  __Pyx_XDECREF(__pyx_v_temp_annos);
  __Pyx_XDECREF(__pyx_v_temp_workspace);
  __Pyx_XDECREF(__pyx_v_vals);
  __Pyx_XDECREF(__pyx_v_isochore);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_10TupleProxy_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_10TupleProxy_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_9GatEngine_10TupleProxy___cinit__(((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2167
 *         int min_fields
 * 
 *     def __cinit__(self ):             # <<<<<<<<<<<<<<
 * 
 *         self.data = NULL
 */

static int __pyx_pf_9GatEngine_10TupleProxy___cinit__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "GatEngine.pyx":2169
 *     def __cinit__(self ):
 * 
 *         self.data = NULL             # <<<<<<<<<<<<<<
 *         self.fields = NULL
 *         self.index = 0
 */
  __pyx_v_self->data = NULL;

  /* "GatEngine.pyx":2170
 * 
 *         self.data = NULL
 *         self.fields = NULL             # <<<<<<<<<<<<<<
 *         self.index = 0
 *         self.nfields = 0
 */
  __pyx_v_self->fields = NULL;

  /* "GatEngine.pyx":2171
 *         self.data = NULL
 *         self.fields = NULL
 *         self.index = 0             # <<<<<<<<<<<<<<
 *         self.nfields = 0
 *         self.min_fields = 0
 */
  __pyx_v_self->index = 0;

  /* "GatEngine.pyx":2172
 *         self.fields = NULL
 *         self.index = 0
 *         self.nfields = 0             # <<<<<<<<<<<<<<
 *         self.min_fields = 0
 * 
 */
  __pyx_v_self->nfields = 0;

  /* "GatEngine.pyx":2173
 *         self.index = 0
 *         self.nfields = 0
 *         self.min_fields = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef take( self, char * buffer, size_t nbytes ):
 */
  __pyx_v_self->min_fields = 0;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2175
 *         self.min_fields = 0
 * 
 *     cdef take( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
 *         '''start presenting buffer.
 * 
 */

static PyObject *__pyx_f_9GatEngine_10TupleProxy_take(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("take", 0);

  /* "GatEngine.pyx":2180
 *         Take ownership of the pointer.
 *         '''
 *         if self.data != NULL:             # <<<<<<<<<<<<<<
 *             free(self.data)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->data != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2181
 *         '''
 *         if self.data != NULL:
 *             free(self.data)             # <<<<<<<<<<<<<<
 * 
 *         self.data = buffer
 */
    free(__pyx_v_self->data);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2183
 *             free(self.data)
 * 
 *         self.data = buffer             # <<<<<<<<<<<<<<
 *         self.update( buffer, nbytes )
 * 
 */
  __pyx_v_self->data = __pyx_v_buffer;

  /* "GatEngine.pyx":2184
 * 
 *         self.data = buffer
 *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
 * 
 *     cdef present( self, char * buffer, size_t nbytes ):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_9GatEngine_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.TupleProxy.take", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2186
 *         self.update( buffer, nbytes )
 * 
 *     cdef present( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
 *         '''start presenting buffer.
 * 
 */

static PyObject *__pyx_f_9GatEngine_10TupleProxy_present(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("present", 0);

  /* "GatEngine.pyx":2191
 *         Do not take ownership of the pointer.
 *         '''
 *         if self.data != NULL:             # <<<<<<<<<<<<<<
 *             free(self.data)
 *             self.data = NULL
 */
  __pyx_t_1 = (__pyx_v_self->data != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2192
 *         '''
 *         if self.data != NULL:
 *             free(self.data)             # <<<<<<<<<<<<<<
 *             self.data = NULL
 * 
 */
    free(__pyx_v_self->data);

    /* "GatEngine.pyx":2193
 *         if self.data != NULL:
 *             free(self.data)
 *             self.data = NULL             # <<<<<<<<<<<<<<
 * 
 *         self.update( buffer, nbytes )
 */
    __pyx_v_self->data = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2195
 *             self.data = NULL
 * 
 *         self.update( buffer, nbytes )             # <<<<<<<<<<<<<<
 * 
 *     cdef copy( self, char * buffer, size_t nbytes ):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_9GatEngine_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_buffer, __pyx_v_nbytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.TupleProxy.present", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2197
 *         self.update( buffer, nbytes )
 * 
 *     cdef copy( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
 *         '''start presenting buffer.
 * 
 */

static PyObject *__pyx_f_9GatEngine_10TupleProxy_copy(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
  int __pyx_v_s;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "GatEngine.pyx":2202
 *         Take a copy of buffer.
 *         '''
 *         if self.data != NULL:             # <<<<<<<<<<<<<<
 *             free(self.data)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->data != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2203
 *         '''
 *         if self.data != NULL:
 *             free(self.data)             # <<<<<<<<<<<<<<
 * 
 *         cdef int s
 */
    free(__pyx_v_self->data);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2206
 * 
 *         cdef int s
 *         s = sizeof(char) * nbytes             # <<<<<<<<<<<<<<
 *         self.data = <char*>malloc( s )
 *         if not self.data: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( s ) )
 */
  __pyx_v_s = ((sizeof(char)) * __pyx_v_nbytes);

  /* "GatEngine.pyx":2207
 *         cdef int s
 *         s = sizeof(char) * nbytes
 *         self.data = <char*>malloc( s )             # <<<<<<<<<<<<<<
 *         if not self.data: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( s ) )
 *         memcpy( <char*>self.data, buffer, s )
 */
  __pyx_v_self->data = ((char *)malloc(__pyx_v_s));

  /* "GatEngine.pyx":2208
 *         s = sizeof(char) * nbytes
 *         self.data = <char*>malloc( s )
 *         if not self.data: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( s ) )             # <<<<<<<<<<<<<<
 *         memcpy( <char*>self.data, buffer, s )
 *         self.update( self.data, nbytes )
 */
  __pyx_t_1 = (!(__pyx_v_self->data != 0));
  if (__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":2209
 *         self.data = <char*>malloc( s )
 *         if not self.data: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( s ) )
 *         memcpy( <char*>self.data, buffer, s )             # <<<<<<<<<<<<<<
 *         self.update( self.data, nbytes )
 * 
 */
  memcpy(((char *)__pyx_v_self->data), __pyx_v_buffer, __pyx_v_s);

  /* "GatEngine.pyx":2210
 *         if not self.data: raise MemoryError( "out of memory when allocation %i bytes" % sizeof( s ) )
 *         memcpy( <char*>self.data, buffer, s )
 *         self.update( self.data, nbytes )             # <<<<<<<<<<<<<<
 * 
 *     cdef update( self, char * buffer, size_t nbytes ):
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_9GatEngine_TupleProxy *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_self->data, __pyx_v_nbytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.TupleProxy.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2212
 *         self.update( self.data, nbytes )
 * 
 *     cdef update( self, char * buffer, size_t nbytes ):             # <<<<<<<<<<<<<<
 *         '''update internal data.'''
 *         cdef char * pos
 */

static PyObject *__pyx_f_9GatEngine_10TupleProxy_update(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self, char *__pyx_v_buffer, size_t __pyx_v_nbytes) {
  char *__pyx_v_pos;
  char *__pyx_v_old_pos;
  int __pyx_v_field;
  int __pyx_v_max_fields;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("update", 0);

  /* "GatEngine.pyx":2218
 *         cdef int field
 *         cdef int max_fields
 *         field = 0             # <<<<<<<<<<<<<<
 * 
 *         if buffer[nbytes-1] != 0:
 */
  __pyx_v_field = 0;

  /* "GatEngine.pyx":2220
 *         field = 0
 * 
 *         if buffer[nbytes-1] != 0:             # <<<<<<<<<<<<<<
 *             raise ValueError( "incomplete line at %s: %s" % (buffer, buffer[nbytes-1]) )
 * 
 */
  __pyx_t_1 = ((__pyx_v_buffer[(__pyx_v_nbytes - 1)]) != 0);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2221
 * 
 *         if buffer[nbytes-1] != 0:
 *             raise ValueError( "incomplete line at %s: %s" % (buffer, buffer[nbytes-1]) )             # <<<<<<<<<<<<<<
 * 
 *         if self.fields != NULL:
 */
    __pyx_t_2 = PyBytes_FromString(__pyx_v_buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyInt_FromLong((__pyx_v_buffer[(__pyx_v_nbytes - 1)])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_42), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2223
 *             raise ValueError( "incomplete line at %s: %s" % (buffer, buffer[nbytes-1]) )
 * 
 *         if self.fields != NULL:             # <<<<<<<<<<<<<<
 *             free(self.fields)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->fields != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2224
 * 
 *         if self.fields != NULL:
 *             free(self.fields)             # <<<<<<<<<<<<<<
 * 
 *         max_fields = nbytes / 2
 */
    free(__pyx_v_self->fields);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":2226
 *             free(self.fields)
 * 
 *         max_fields = nbytes / 2             # <<<<<<<<<<<<<<
 *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
 * 
 */
  __pyx_v_max_fields = (__pyx_v_nbytes / 2);

  /* "GatEngine.pyx":2227
 * 
 *         max_fields = nbytes / 2
 *         self.fields = <char **>calloc( max_fields, sizeof(char *) )             # <<<<<<<<<<<<<<
 * 
 *         pos = buffer
 */
  __pyx_v_self->fields = ((char **)calloc(__pyx_v_max_fields, (sizeof(char *))));

  /* "GatEngine.pyx":2229
 *         self.fields = <char **>calloc( max_fields, sizeof(char *) )
 * 
 *         pos = buffer             # <<<<<<<<<<<<<<
 *         self.fields[0] = pos
 *         field += 1
 */
  __pyx_v_pos = __pyx_v_buffer;

  /* "GatEngine.pyx":2230
 * 
 *         pos = buffer
 *         self.fields[0] = pos             # <<<<<<<<<<<<<<
 *         field += 1
 *         old_pos = pos
 */
  (__pyx_v_self->fields[0]) = __pyx_v_pos;

  /* "GatEngine.pyx":2231
 *         pos = buffer
 *         self.fields[0] = pos
 *         field += 1             # <<<<<<<<<<<<<<
 *         old_pos = pos
 * 
 */
  __pyx_v_field = (__pyx_v_field + 1);

  /* "GatEngine.pyx":2232
 *         self.fields[0] = pos
 *         field += 1
 *         old_pos = pos             # <<<<<<<<<<<<<<
 * 
 *         while 1:
 */
  __pyx_v_old_pos = __pyx_v_pos;

  /* "GatEngine.pyx":2234
 *         old_pos = pos
 * 
 *         while 1:             # <<<<<<<<<<<<<<
 * 
 *             pos = <char*>memchr( pos, '\t', nbytes )
 */
  while (1) {
    if (!1) break;

    /* "GatEngine.pyx":2236
 *         while 1:
 * 
 *             pos = <char*>memchr( pos, '\t', nbytes )             # <<<<<<<<<<<<<<
 *             if pos == NULL: break
 *             pos[0] = '\0'
 */
    __pyx_v_pos = ((char *)memchr(__pyx_v_pos, '\t', __pyx_v_nbytes));

    /* "GatEngine.pyx":2237
 * 
 *             pos = <char*>memchr( pos, '\t', nbytes )
 *             if pos == NULL: break             # <<<<<<<<<<<<<<
 *             pos[0] = '\0'
 *             pos += 1
 */
    __pyx_t_1 = (__pyx_v_pos == NULL);
    if (__pyx_t_1) {
      goto __pyx_L6_break;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "GatEngine.pyx":2238
 *             pos = <char*>memchr( pos, '\t', nbytes )
 *             if pos == NULL: break
 *             pos[0] = '\0'             # <<<<<<<<<<<<<<
 *             pos += 1
 *             self.fields[field] = pos
 */
    (__pyx_v_pos[0]) = '\x00';

    /* "GatEngine.pyx":2239
 *             if pos == NULL: break
 *             pos[0] = '\0'
 *             pos += 1             # <<<<<<<<<<<<<<
 *             self.fields[field] = pos
 *             field += 1
 */
    __pyx_v_pos = (__pyx_v_pos + 1);

    /* "GatEngine.pyx":2240
 *             pos[0] = '\0'
 *             pos += 1
 *             self.fields[field] = pos             # <<<<<<<<<<<<<<
 *             field += 1
 *             if field >= max_fields:
 */
    (__pyx_v_self->fields[__pyx_v_field]) = __pyx_v_pos;

    /* "GatEngine.pyx":2241
 *             pos += 1
 *             self.fields[field] = pos
 *             field += 1             # <<<<<<<<<<<<<<
 *             if field >= max_fields:
 *                 raise ValueError("row too large - more than %i fields" % max_fields )
 */
    __pyx_v_field = (__pyx_v_field + 1);

    /* "GatEngine.pyx":2242
 *             self.fields[field] = pos
 *             field += 1
 *             if field >= max_fields:             # <<<<<<<<<<<<<<
 *                 raise ValueError("row too large - more than %i fields" % max_fields )
 *             nbytes -= pos - old_pos
 */
    __pyx_t_1 = (__pyx_v_field >= __pyx_v_max_fields);
    if (__pyx_t_1) {

      /* "GatEngine.pyx":2243
 *             field += 1
 *             if field >= max_fields:
 *                 raise ValueError("row too large - more than %i fields" % max_fields )             # <<<<<<<<<<<<<<
 *             nbytes -= pos - old_pos
 *             if nbytes < 0: break
 */
      __pyx_t_3 = PyInt_FromLong(__pyx_v_max_fields); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_43), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "GatEngine.pyx":2244
 *             if field >= max_fields:
 *                 raise ValueError("row too large - more than %i fields" % max_fields )
 *             nbytes -= pos - old_pos             # <<<<<<<<<<<<<<
 *             if nbytes < 0: break
 *             old_pos = pos
 */
    __pyx_v_nbytes = (__pyx_v_nbytes - (__pyx_v_pos - __pyx_v_old_pos));

    /* "GatEngine.pyx":2245
 *                 raise ValueError("row too large - more than %i fields" % max_fields )
 *             nbytes -= pos - old_pos
 *             if nbytes < 0: break             # <<<<<<<<<<<<<<
 *             old_pos = pos
 * 
 */
    __pyx_t_1 = (__pyx_v_nbytes < 0);
    if (__pyx_t_1) {
      goto __pyx_L6_break;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "GatEngine.pyx":2246
 *             nbytes -= pos - old_pos
 *             if nbytes < 0: break
 *             old_pos = pos             # <<<<<<<<<<<<<<
 * 
 *         self.nfields = field
 */
    __pyx_v_old_pos = __pyx_v_pos;
  }
  __pyx_L6_break:;

  /* "GatEngine.pyx":2248
 *             old_pos = pos
 * 
 *         self.nfields = field             # <<<<<<<<<<<<<<
 * 
 *         if self.nfields < self.min_fields:
 */
  __pyx_v_self->nfields = __pyx_v_field;

  /* "GatEngine.pyx":2250
 *         self.nfields = field
 * 
 *         if self.nfields < self.min_fields:             # <<<<<<<<<<<<<<
 *             raise IOError("not enough fields, expected >%i, got %i" % \
 *                               (self.min_fields, self.nfields))
 */
  __pyx_t_1 = (__pyx_v_self->nfields < __pyx_v_self->min_fields);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2252
 *         if self.nfields < self.min_fields:
 *             raise IOError("not enough fields, expected >%i, got %i" % \
 *                               (self.min_fields, self.nfields))             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__( self, key ):
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_self->min_fields); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_self->nfields); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_44), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.TupleProxy.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_10TupleProxy_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_9GatEngine_10TupleProxy_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_10TupleProxy_2__getitem__(((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2254
 *                               (self.min_fields, self.nfields))
 * 
 *     def __getitem__( self, key ):             # <<<<<<<<<<<<<<
 * 
 *         cdef int i
 */

static PyObject *__pyx_pf_9GatEngine_10TupleProxy_2__getitem__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "GatEngine.pyx":2257
 * 
 *         cdef int i
 *         i = key             # <<<<<<<<<<<<<<
 *         if i < 0: i += self.nfields
 *         if i >= self.nfields or i < 0:
 */
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_key); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_i = __pyx_t_1;

  /* "GatEngine.pyx":2258
 *         cdef int i
 *         i = key
 *         if i < 0: i += self.nfields             # <<<<<<<<<<<<<<
 *         if i >= self.nfields or i < 0:
 *             raise IndexError( "list index out of range" )
 */
  __pyx_t_2 = (__pyx_v_i < 0);
  if (__pyx_t_2) {
    __pyx_v_i = (__pyx_v_i + __pyx_v_self->nfields);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2259
 *         i = key
 *         if i < 0: i += self.nfields
 *         if i >= self.nfields or i < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError( "list index out of range" )
 *         return self.fields[i]
 */
  __pyx_t_2 = (__pyx_v_i >= __pyx_v_self->nfields);
  if (!__pyx_t_2) {
    __pyx_t_3 = (__pyx_v_i < 0);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "GatEngine.pyx":2260
 *         if i < 0: i += self.nfields
 *         if i >= self.nfields or i < 0:
 *             raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
 *         return self.fields[i]
 * 
 */
    __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_46), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":2261
 *         if i >= self.nfields or i < 0:
 *             raise IndexError( "list index out of range" )
 *         return self.fields[i]             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyBytes_FromString((__pyx_v_self->fields[__pyx_v_i])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_r = ((PyObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.TupleProxy.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static Py_ssize_t __pyx_pw_9GatEngine_10TupleProxy_5__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_9GatEngine_10TupleProxy_5__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_10TupleProxy_4__len__(((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2263
 *         return self.fields[i]
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.nfields
 * 
 */

static Py_ssize_t __pyx_pf_9GatEngine_10TupleProxy_4__len__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "GatEngine.pyx":2264
 * 
 *     def __len__(self):
 *         return self.nfields             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_r = __pyx_v_self->nfields;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_10TupleProxy_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_10TupleProxy_7__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_10TupleProxy_6__dealloc__(((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":2266
 *         return self.nfields
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.data != NULL:
 *             free(self.data)
 */

static void __pyx_pf_9GatEngine_10TupleProxy_6__dealloc__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":2267
 * 
 *     def __dealloc__(self):
 *         if self.data != NULL:             # <<<<<<<<<<<<<<
 *             free(self.data)
 *         if self.fields != NULL:
 */
  __pyx_t_1 = (__pyx_v_self->data != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2268
 *     def __dealloc__(self):
 *         if self.data != NULL:
 *             free(self.data)             # <<<<<<<<<<<<<<
 *         if self.fields != NULL:
 *             free(self.fields)
 */
    free(__pyx_v_self->data);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2269
 *         if self.data != NULL:
 *             free(self.data)
 *         if self.fields != NULL:             # <<<<<<<<<<<<<<
 *             free(self.fields)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->fields != NULL);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2270
 *             free(self.data)
 *         if self.fields != NULL:
 *             free(self.fields)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
    free(__pyx_v_self->fields);
    goto __pyx_L4;
  }
  __pyx_L4:;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_10TupleProxy_9__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_10TupleProxy_9__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_10TupleProxy_8__iter__(((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2272
 *             free(self.fields)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         self.index = 0
 *         return self
 */

static PyObject *__pyx_pf_9GatEngine_10TupleProxy_8__iter__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "GatEngine.pyx":2273
 * 
 *     def __iter__(self):
 *         self.index = 0             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_v_self->index = 0;

  /* "GatEngine.pyx":2274
 *     def __iter__(self):
 *         self.index = 0
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_10TupleProxy_11__next__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9GatEngine_10TupleProxy_10__next__[] = "python version of next().\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_10TupleProxy_10__next__;
#endif
static PyObject *__pyx_pw_9GatEngine_10TupleProxy_11__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_10TupleProxy_10__next__(((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2276
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """python version of next().
 *         """
 */

static PyObject *__pyx_pf_9GatEngine_10TupleProxy_10__next__(struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "GatEngine.pyx":2279
 *         """python version of next().
 *         """
 *         if self.index >= self.nfields:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         self.index += 1
 */
  __pyx_t_1 = (__pyx_v_self->index >= __pyx_v_self->nfields);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2280
 *         """
 *         if self.index >= self.nfields:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         self.index += 1
 *         return self.fields[self.index-1]
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2281
 *         if self.index >= self.nfields:
 *             raise StopIteration
 *         self.index += 1             # <<<<<<<<<<<<<<
 *         return self.fields[self.index-1]
 * 
 */
  __pyx_v_self->index = (__pyx_v_self->index + 1);

  /* "GatEngine.pyx":2282
 *             raise StopIteration
 *         self.index += 1
 *         return self.fields[self.index-1]             # <<<<<<<<<<<<<<
 * 
 * cdef class BedProxy( TupleProxy ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyBytes_FromString((__pyx_v_self->fields[(__pyx_v_self->index - 1)])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.TupleProxy.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_8BedProxy_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_8BedProxy_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_track = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.BedProxy.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_8BedProxy___init__(((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_v_self), __pyx_v_track);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2287
 * 
 *    cdef track
 *    def __init__(self, track ):             # <<<<<<<<<<<<<<
 *        self.track = track
 *        self.min_fields = 3
 */

static int __pyx_pf_9GatEngine_8BedProxy___init__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self, PyObject *__pyx_v_track) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2288
 *    cdef track
 *    def __init__(self, track ):
 *        self.track = track             # <<<<<<<<<<<<<<
 *        self.min_fields = 3
 * 
 */
  __Pyx_INCREF(__pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_GOTREF(__pyx_v_self->track);
  __Pyx_DECREF(__pyx_v_self->track);
  __pyx_v_self->track = __pyx_v_track;

  /* "GatEngine.pyx":2289
 *    def __init__(self, track ):
 *        self.track = track
 *        self.min_fields = 3             # <<<<<<<<<<<<<<
 * 
 *    property contig:
 */
  __pyx_v_self->__pyx_base.min_fields = 3;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_8BedProxy_6contig_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_8BedProxy_6contig_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_8BedProxy_6contig___get__(((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2292
 * 
 *    property contig:
 *        def __get__(self):             # <<<<<<<<<<<<<<
 *            return self.fields[0]
 * 
 */

static PyObject *__pyx_pf_9GatEngine_8BedProxy_6contig___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "GatEngine.pyx":2293
 *    property contig:
 *        def __get__(self):
 *            return self.fields[0]             # <<<<<<<<<<<<<<
 * 
 *    property start:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromString((__pyx_v_self->__pyx_base.fields[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.BedProxy.contig.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_8BedProxy_5start_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_8BedProxy_5start_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_8BedProxy_5start___get__(((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2296
 * 
 *    property start:
 *        def __get__(self):             # <<<<<<<<<<<<<<
 *            return atol(self.fields[1])
 * 
 */

static PyObject *__pyx_pf_9GatEngine_8BedProxy_5start___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "GatEngine.pyx":2297
 *    property start:
 *        def __get__(self):
 *            return atol(self.fields[1])             # <<<<<<<<<<<<<<
 * 
 *    property end:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(atol((__pyx_v_self->__pyx_base.fields[1]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.BedProxy.start.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_8BedProxy_3end_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_8BedProxy_3end_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_8BedProxy_3end___get__(((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2300
 * 
 *    property end:
 *        def __get__(self):             # <<<<<<<<<<<<<<
 *            return atol(self.fields[2])
 * 
 */

static PyObject *__pyx_pf_9GatEngine_8BedProxy_3end___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "GatEngine.pyx":2301
 *    property end:
 *        def __get__(self):
 *            return atol(self.fields[2])             # <<<<<<<<<<<<<<
 * 
 *    property name:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(atol((__pyx_v_self->__pyx_base.fields[2]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.BedProxy.end.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_8BedProxy_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_8BedProxy_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_8BedProxy_4name___get__(((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2304
 * 
 *    property name:
 *        def __get__(self):             # <<<<<<<<<<<<<<
 *            if self.nfields >= 4:
 *                return self.fields[3]
 */

static PyObject *__pyx_pf_9GatEngine_8BedProxy_4name___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "GatEngine.pyx":2305
 *    property name:
 *        def __get__(self):
 *            if self.nfields >= 4:             # <<<<<<<<<<<<<<
 *                return self.fields[3]
 *            else:
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.nfields >= 4);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2306
 *        def __get__(self):
 *            if self.nfields >= 4:
 *                return self.fields[3]             # <<<<<<<<<<<<<<
 *            else:
 *                return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyBytes_FromString((__pyx_v_self->__pyx_base.fields[3])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":2308
 *                return self.fields[3]
 *            else:
 *                return None             # <<<<<<<<<<<<<<
 * 
 *    property track:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.BedProxy.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_8BedProxy_5track_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_8BedProxy_5track_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_8BedProxy_5track___get__(((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2311
 * 
 *    property track:
 *        def __get__(self):             # <<<<<<<<<<<<<<
 *            return self.track
 * 
 */

static PyObject *__pyx_pf_9GatEngine_8BedProxy_5track___get__(struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "GatEngine.pyx":2312
 *    property track:
 *        def __get__(self):
 *            return self.track             # <<<<<<<<<<<<<<
 * 
 * class Track(object):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->track);
  __pyx_r = __pyx_v_self->track;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_5Track_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_5Track___init__[] = "Track.__init__(self, line)";
static PyMethodDef __pyx_mdef_9GatEngine_5Track_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_9GatEngine_5Track_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_5Track___init__)};
static PyObject *__pyx_pw_9GatEngine_5Track_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_line = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_line = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.Track.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_5Track___init__(__pyx_self, __pyx_v_self, __pyx_v_line);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2316
 * class Track(object):
 *     '''bed track information.'''
 *     def __init__(self, line ):             # <<<<<<<<<<<<<<
 *         r= re.compile('([^\s=]+) *= *("[^"]*"|[^ ]*)')
 * 
 */

static PyObject *__pyx_pf_9GatEngine_5Track___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_line) {
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2317
 *     '''bed track information.'''
 *     def __init__(self, line ):
 *         r= re.compile('([^\s=]+) *= *("[^"]*"|[^ ]*)')             # <<<<<<<<<<<<<<
 * 
 *         self._d = {}
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__compile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_r = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":2319
 *         r= re.compile('([^\s=]+) *= *("[^"]*"|[^ ]*)')
 * 
 *         self._d = {}             # <<<<<<<<<<<<<<
 *         for k, v in r.findall(line[:-1]):
 *             if v[:1]=='"':
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___d, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2320
 * 
 *         self._d = {}
 *         for k, v in r.findall(line[:-1]):             # <<<<<<<<<<<<<<
 *             if v[:1]=='"':
 *                 self._d[k] = v[1:-1]
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_r, __pyx_n_s__findall); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_line, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_k);
    __pyx_v_k = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_v);
    __pyx_v_v = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2321
 *         self._d = {}
 *         for k, v in r.findall(line[:-1]):
 *             if v[:1]=='"':             # <<<<<<<<<<<<<<
 *                 self._d[k] = v[1:-1]
 *             else:
 */
    __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_v, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_kp_s_49), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_9) {

      /* "GatEngine.pyx":2322
 *         for k, v in r.findall(line[:-1]):
 *             if v[:1]=='"':
 *                 self._d[k] = v[1:-1]             # <<<<<<<<<<<<<<
 *             else:
 *                 self._d[k] = v
 */
      __pyx_t_6 = __Pyx_PySequence_GetSlice(__pyx_v_v, 1, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_t_2, __pyx_v_k, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "GatEngine.pyx":2324
 *                 self._d[k] = v[1:-1]
 *             else:
 *                 self._d[k] = v             # <<<<<<<<<<<<<<
 * 
 *         self._line = line[:-1]
 */
      __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___d); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (PyObject_SetItem(__pyx_t_6, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2326
 *                 self._d[k] = v
 * 
 *         self._line = line[:-1]             # <<<<<<<<<<<<<<
 *     def __str__(self):
 *         return self._line
 */
  __pyx_t_3 = __Pyx_PySequence_GetSlice(__pyx_v_line, 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___line, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.Track.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_5Track_3__str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9GatEngine_5Track_2__str__[] = "Track.__str__(self)";
static PyMethodDef __pyx_mdef_9GatEngine_5Track_3__str__ = {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pw_9GatEngine_5Track_3__str__, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_5Track_2__str__)};
static PyObject *__pyx_pw_9GatEngine_5Track_3__str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_5Track_2__str__(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2327
 * 
 *         self._line = line[:-1]
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self._line
 * 
 */

static PyObject *__pyx_pf_9GatEngine_5Track_2__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "GatEngine.pyx":2328
 *         self._line = line[:-1]
 *     def __str__(self):
 *         return self._line             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key): return self._d[key]
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.Track.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_5Track_5__getitem__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_5Track_4__getitem__[] = "Track.__getitem__(self, key)";
static PyMethodDef __pyx_mdef_9GatEngine_5Track_5__getitem__ = {__Pyx_NAMESTR("__getitem__"), (PyCFunction)__pyx_pw_9GatEngine_5Track_5__getitem__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_5Track_4__getitem__)};
static PyObject *__pyx_pw_9GatEngine_5Track_5__getitem__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__key,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__getitem__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__getitem__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_key = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__getitem__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.Track.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_5Track_4__getitem__(__pyx_self, __pyx_v_self, __pyx_v_key);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2330
 *         return self._line
 * 
 *     def __getitem__(self, key): return self._d[key]             # <<<<<<<<<<<<<<
 *     def __setitem__(self, key,val): self._d[key] = val
 * 
 */

static PyObject *__pyx_pf_9GatEngine_5Track_4__getitem__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.Track.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_5Track_7__setitem__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_5Track_6__setitem__[] = "Track.__setitem__(self, key, val)";
static PyMethodDef __pyx_mdef_9GatEngine_5Track_7__setitem__ = {__Pyx_NAMESTR("__setitem__"), (PyCFunction)__pyx_pw_9GatEngine_5Track_7__setitem__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_5Track_6__setitem__)};
static PyObject *__pyx_pw_9GatEngine_5Track_7__setitem__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_val = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__key,&__pyx_n_s__val,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__setitem__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__val)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__setitem__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__setitem__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_key = values[1];
    __pyx_v_val = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__setitem__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.Track.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_5Track_6__setitem__(__pyx_self, __pyx_v_self, __pyx_v_key, __pyx_v_val);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2331
 * 
 *     def __getitem__(self, key): return self._d[key]
 *     def __setitem__(self, key,val): self._d[key] = val             # <<<<<<<<<<<<<<
 * 
 * class tsv_iterator:
 */

static PyObject *__pyx_pf_9GatEngine_5Track_6__setitem__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_val) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_1, __pyx_v_key, __pyx_v_val) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.Track.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12tsv_iterator___init__[] = "tsv_iterator.__init__(self, infile)";
static PyMethodDef __pyx_mdef_9GatEngine_12tsv_iterator_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_9GatEngine_12tsv_iterator_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12tsv_iterator___init__)};
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_infile = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__infile,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_infile = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.tsv_iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_12tsv_iterator___init__(__pyx_self, __pyx_v_self, __pyx_v_infile);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2338
 *     Permits the use of file-like objects for example from the gzip module.
 *     '''
 *     def __init__(self, infile ):             # <<<<<<<<<<<<<<
 * 
 *         self.infile = infile
 */

static PyObject *__pyx_pf_9GatEngine_12tsv_iterator___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_infile) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2340
 *     def __init__(self, infile ):
 * 
 *         self.infile = infile             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__infile, __pyx_v_infile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.tsv_iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9GatEngine_12tsv_iterator_2__iter__[] = "tsv_iterator.__iter__(self)";
static PyMethodDef __pyx_mdef_9GatEngine_12tsv_iterator_3__iter__ = {__Pyx_NAMESTR("__iter__"), (PyCFunction)__pyx_pw_9GatEngine_12tsv_iterator_3__iter__, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12tsv_iterator_2__iter__)};
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_12tsv_iterator_2__iter__(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2342
 *         self.infile = infile
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "GatEngine.pyx":2343
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def preparse( self, line ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_5preparse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12tsv_iterator_4preparse[] = "tsv_iterator.preparse(self, line)";
static PyMethodDef __pyx_mdef_9GatEngine_12tsv_iterator_5preparse = {__Pyx_NAMESTR("preparse"), (PyCFunction)__pyx_pw_9GatEngine_12tsv_iterator_5preparse, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12tsv_iterator_4preparse)};
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_5preparse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_line = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("preparse (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("preparse", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "preparse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_line = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("preparse", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.tsv_iterator.preparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_12tsv_iterator_4preparse(__pyx_self, __pyx_v_self, __pyx_v_line);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2345
 *         return self
 * 
 *     def preparse( self, line ):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_4preparse(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_line) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("preparse", 0);

  /* "GatEngine.pyx":2346
 * 
 *     def preparse( self, line ):
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def create( self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.tsv_iterator.preparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_7create(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9GatEngine_12tsv_iterator_6create[] = "tsv_iterator.create(self)";
static PyMethodDef __pyx_mdef_9GatEngine_12tsv_iterator_7create = {__Pyx_NAMESTR("create"), (PyCFunction)__pyx_pw_9GatEngine_12tsv_iterator_7create, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12tsv_iterator_6create)};
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_7create(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_12tsv_iterator_6create(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2348
 *         return True
 * 
 *     def create( self):             # <<<<<<<<<<<<<<
 *         return TupleProxy()
 * 
 */

static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_6create(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create", 0);

  /* "GatEngine.pyx":2349
 * 
 *     def create( self):
 *         return TupleProxy()             # <<<<<<<<<<<<<<
 * 
 *     def next(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_TupleProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.tsv_iterator.create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_9next(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9GatEngine_12tsv_iterator_8next[] = "tsv_iterator.next(self)";
static PyMethodDef __pyx_mdef_9GatEngine_12tsv_iterator_9next = {__Pyx_NAMESTR("next"), (PyCFunction)__pyx_pw_9GatEngine_12tsv_iterator_9next, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12tsv_iterator_8next)};
static PyObject *__pyx_pw_9GatEngine_12tsv_iterator_9next(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("next (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_12tsv_iterator_8next(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2351
 *         return TupleProxy()
 * 
 *     def next(self):             # <<<<<<<<<<<<<<
 * 
 *         cdef char * b
 */

static PyObject *__pyx_pf_9GatEngine_12tsv_iterator_8next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  char *__pyx_v_b;
  struct __pyx_obj_9GatEngine_TupleProxy *__pyx_v_r = 0;
  size_t __pyx_v_nbytes;
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  char *__pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("next", 0);

  /* "GatEngine.pyx":2358
 *         cdef size_t nbytes
 * 
 *         track = None             # <<<<<<<<<<<<<<
 * 
 *         while 1:
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_track = Py_None;

  /* "GatEngine.pyx":2360
 *         track = None
 * 
 *         while 1:             # <<<<<<<<<<<<<<
 * 
 *             line = self.infile.readline()
 */
  while (1) {
    if (!1) break;

    /* "GatEngine.pyx":2362
 *         while 1:
 * 
 *             line = self.infile.readline()             # <<<<<<<<<<<<<<
 *             if not line: break
 * 
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__infile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__readline); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_v_line);
    __pyx_v_line = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "GatEngine.pyx":2363
 * 
 *             line = self.infile.readline()
 *             if not line: break             # <<<<<<<<<<<<<<
 * 
 *             # string conversion - b references internal string in python object
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_line); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = (!__pyx_t_3);
    if (__pyx_t_4) {
      goto __pyx_L4_break;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "GatEngine.pyx":2366
 * 
 *             # string conversion - b references internal string in python object
 *             b = line             # <<<<<<<<<<<<<<
 * 
 *             # nbytes includes new line but not \0
 */
    __pyx_t_5 = PyBytes_AsString(__pyx_v_line); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_b = __pyx_t_5;

    /* "GatEngine.pyx":2369
 * 
 *             # nbytes includes new line but not \0
 *             nbytes = len( line )             # <<<<<<<<<<<<<<
 * 
 *             # skip comments
 */
    __pyx_t_6 = PyObject_Length(__pyx_v_line); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_nbytes = __pyx_t_6;

    /* "GatEngine.pyx":2372
 * 
 *             # skip comments
 *             if (b[0] == '#'): continue             # <<<<<<<<<<<<<<
 * 
 *             # skip empty lines
 */
    __pyx_t_4 = ((__pyx_v_b[0]) == '#');
    if (__pyx_t_4) {
      goto __pyx_L3_continue;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "GatEngine.pyx":2375
 * 
 *             # skip empty lines
 *             if b[0] == '\0' or b[0] == '\n': continue             # <<<<<<<<<<<<<<
 * 
 *             if not self.preparse(line): continue
 */
    __pyx_t_4 = ((__pyx_v_b[0]) == '\x00');
    if (!__pyx_t_4) {
      __pyx_t_3 = ((__pyx_v_b[0]) == '\n');
      __pyx_t_7 = __pyx_t_3;
    } else {
      __pyx_t_7 = __pyx_t_4;
    }
    if (__pyx_t_7) {
      goto __pyx_L3_continue;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "GatEngine.pyx":2377
 *             if b[0] == '\0' or b[0] == '\n': continue
 * 
 *             if not self.preparse(line): continue             # <<<<<<<<<<<<<<
 * 
 *             # make sure that entry is complete
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__preparse); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_line);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
    __Pyx_GIVEREF(__pyx_v_line);
    __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_4 = (!__pyx_t_7);
    if (__pyx_t_4) {
      goto __pyx_L3_continue;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "GatEngine.pyx":2380
 * 
 *             # make sure that entry is complete
 *             if b[nbytes-1] != '\n':             # <<<<<<<<<<<<<<
 *                 raise ValueError( "incomplete line at %s" % line )
 * 
 */
    __pyx_t_4 = ((__pyx_v_b[(__pyx_v_nbytes - 1)]) != '\n');
    if (__pyx_t_4) {

      /* "GatEngine.pyx":2381
 *             # make sure that entry is complete
 *             if b[nbytes-1] != '\n':
 *                 raise ValueError( "incomplete line at %s" % line )             # <<<<<<<<<<<<<<
 * 
 *             # chop off newline
 */
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_50), __pyx_v_line); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "GatEngine.pyx":2384
 * 
 *             # chop off newline
 *             b[nbytes-1] = '\0'             # <<<<<<<<<<<<<<
 * 
 *             # create a copy
 */
    (__pyx_v_b[(__pyx_v_nbytes - 1)]) = '\x00';

    /* "GatEngine.pyx":2387
 * 
 *             # create a copy
 *             r = self.create()             # <<<<<<<<<<<<<<
 *             r.copy( b, nbytes )
 *             return r
 */
    __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__create); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9GatEngine_TupleProxy))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_r = ((struct __pyx_obj_9GatEngine_TupleProxy *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2388
 *             # create a copy
 *             r = self.create()
 *             r.copy( b, nbytes )             # <<<<<<<<<<<<<<
 *             return r
 * 
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_9GatEngine_TupleProxy *)__pyx_v_r->__pyx_vtab)->copy(__pyx_v_r, __pyx_v_b, __pyx_v_nbytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "GatEngine.pyx":2389
 *             r = self.create()
 *             r.copy( b, nbytes )
 *             return r             # <<<<<<<<<<<<<<
 * 
 *         raise StopIteration
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_r));
    __pyx_r = ((PyObject *)__pyx_v_r);
    goto __pyx_L0;
    __pyx_L3_continue:;
  }
  __pyx_L4_break:;

  /* "GatEngine.pyx":2391
 *             return r
 * 
 *         raise StopIteration             # <<<<<<<<<<<<<<
 * 
 * class bed_iterator(tsv_iterator):
 */
  __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.tsv_iterator.next", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12bed_iterator_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12bed_iterator___init__[] = "bed_iterator.__init__(self, infile)";
static PyMethodDef __pyx_mdef_9GatEngine_12bed_iterator_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_9GatEngine_12bed_iterator_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12bed_iterator___init__)};
static PyObject *__pyx_pw_9GatEngine_12bed_iterator_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_infile = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__infile,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_infile = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.bed_iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_12bed_iterator___init__(__pyx_self, __pyx_v_self, __pyx_v_infile);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2398
 *     Permits the use of file-like objects for example from the gzip module.
 *     '''
 *     def __init__(self, infile ):             # <<<<<<<<<<<<<<
 *         tsv_iterator.__init__(self, infile )
 *         self.track = None
 */

static PyObject *__pyx_pf_9GatEngine_12bed_iterator___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_infile) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2399
 *     '''
 *     def __init__(self, infile ):
 *         tsv_iterator.__init__(self, infile )             # <<<<<<<<<<<<<<
 *         self.track = None
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tsv_iterator); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_infile);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_infile);
  __Pyx_GIVEREF(__pyx_v_infile);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2400
 *     def __init__(self, infile ):
 *         tsv_iterator.__init__(self, infile )
 *         self.track = None             # <<<<<<<<<<<<<<
 * 
 *     def preparse(self, line ):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__track, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.bed_iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12bed_iterator_3preparse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_12bed_iterator_2preparse[] = "bed_iterator.preparse(self, line)";
static PyMethodDef __pyx_mdef_9GatEngine_12bed_iterator_3preparse = {__Pyx_NAMESTR("preparse"), (PyCFunction)__pyx_pw_9GatEngine_12bed_iterator_3preparse, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12bed_iterator_2preparse)};
static PyObject *__pyx_pw_9GatEngine_12bed_iterator_3preparse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_line = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("preparse (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__line,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__line)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("preparse", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "preparse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_line = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("preparse", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.bed_iterator.preparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_12bed_iterator_2preparse(__pyx_self, __pyx_v_self, __pyx_v_line);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2402
 *         self.track = None
 * 
 *     def preparse(self, line ):             # <<<<<<<<<<<<<<
 *         if line.startswith("track"):
 *             self.track = Track( line )
 */

static PyObject *__pyx_pf_9GatEngine_12bed_iterator_2preparse(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_line) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("preparse", 0);

  /* "GatEngine.pyx":2403
 * 
 *     def preparse(self, line ):
 *         if line.startswith("track"):             # <<<<<<<<<<<<<<
 *             self.track = Track( line )
 *             return False
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "GatEngine.pyx":2404
 *     def preparse(self, line ):
 *         if line.startswith("track"):
 *             self.track = Track( line )             # <<<<<<<<<<<<<<
 *             return False
 *         return True
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Track); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_line);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_line);
    __Pyx_GIVEREF(__pyx_v_line);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__track, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "GatEngine.pyx":2405
 *         if line.startswith("track"):
 *             self.track = Track( line )
 *             return False             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2406
 *             self.track = Track( line )
 *             return False
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def create( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.bed_iterator.preparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_12bed_iterator_5create(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9GatEngine_12bed_iterator_4create[] = "bed_iterator.create(self)";
static PyMethodDef __pyx_mdef_9GatEngine_12bed_iterator_5create = {__Pyx_NAMESTR("create"), (PyCFunction)__pyx_pw_9GatEngine_12bed_iterator_5create, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12bed_iterator_4create)};
static PyObject *__pyx_pw_9GatEngine_12bed_iterator_5create(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_12bed_iterator_4create(__pyx_self, ((PyObject *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2408
 *         return True
 * 
 *     def create( self ):             # <<<<<<<<<<<<<<
 *         return BedProxy( self.track )
 * 
 */

static PyObject *__pyx_pf_9GatEngine_12bed_iterator_4create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create", 0);

  /* "GatEngine.pyx":2409
 * 
 *     def create( self ):
 *         return BedProxy( self.track )             # <<<<<<<<<<<<<<
 * 
 * def _genie():
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__track); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_BedProxy)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.bed_iterator.create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_33_genie(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_32_genie[] = "_genie()";
static PyMethodDef __pyx_mdef_9GatEngine_33_genie = {__Pyx_NAMESTR("_genie"), (PyCFunction)__pyx_pw_9GatEngine_33_genie, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_32_genie)};
static PyObject *__pyx_pw_9GatEngine_33_genie(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_genie (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_32_genie(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2411
 *         return BedProxy( self.track )
 * 
 * def _genie():             # <<<<<<<<<<<<<<
 *     return IntervalCollection(SegmentList)
 * 
 */

static PyObject *__pyx_pf_9GatEngine_32_genie(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_genie", 0);

  /* "GatEngine.pyx":2412
 * 
 * def _genie():
 *     return IntervalCollection(SegmentList)             # <<<<<<<<<<<<<<
 * 
 * def readFromBed( filenames, allow_multiple = False ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalCollection)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine._genie", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_35readFromBed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_34readFromBed[] = "readFromBed(filenames, allow_multiple=False)\nread Segment Lists from one or more bed files.\n\n    Segment lists are grouped by *contig* and *track*.\n\n    If no *track* is given, the *name* attribute is taken\n    instead. If that is not present (BED3 format), the\n    *track* is called ``default``.\n\n    If a *track* appears in multiple files, an error is raised\n    unless *allow_multiple* is ``True``.\n    \n    ";
static PyMethodDef __pyx_mdef_9GatEngine_35readFromBed = {__Pyx_NAMESTR("readFromBed"), (PyCFunction)__pyx_pw_9GatEngine_35readFromBed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_34readFromBed)};
static PyObject *__pyx_pw_9GatEngine_35readFromBed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filenames = 0;
  PyObject *__pyx_v_allow_multiple = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("readFromBed (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filenames,&__pyx_n_s__allow_multiple,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k_52;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filenames)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__allow_multiple);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "readFromBed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_filenames = values[0];
    __pyx_v_allow_multiple = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("readFromBed", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.readFromBed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_34readFromBed(__pyx_self, __pyx_v_filenames, __pyx_v_allow_multiple);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2414
 *     return IntervalCollection(SegmentList)
 * 
 * def readFromBed( filenames, allow_multiple = False ):             # <<<<<<<<<<<<<<
 *     '''read Segment Lists from one or more bed files.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_34readFromBed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filenames, PyObject *__pyx_v_allow_multiple) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_l = 0;
  struct __pyx_obj_9GatEngine_BedProxy *__pyx_v_bed = 0;
  __pyx_t_14GatSegmentList_Position __pyx_v_lineno;
  PyObject *__pyx_v_segment_lists = NULL;
  PyObject *__pyx_v_tracks = NULL;
  PyObject *__pyx_v_filename = NULL;
  PyObject *__pyx_v_infile = NULL;
  PyObject *__pyx_v_default_name = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("readFromBed", 0);
  __Pyx_INCREF(__pyx_v_filenames);

  /* "GatEngine.pyx":2431
 *     cdef Position lineno
 * 
 *     segment_lists = collections.defaultdict( IntervalDictionary )             # <<<<<<<<<<<<<<
 * 
 *     tracks = {}
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_segment_lists = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2433
 *     segment_lists = collections.defaultdict( IntervalDictionary )
 * 
 *     tracks = {}             # <<<<<<<<<<<<<<
 * 
 *     if type(filenames) == str:
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_tracks = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2435
 *     tracks = {}
 * 
 *     if type(filenames) == str:             # <<<<<<<<<<<<<<
 *         filenames = (filenames,)
 *     for filename in filenames:
 */
  __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_filenames)), ((PyObject *)((PyObject*)(&PyString_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "GatEngine.pyx":2436
 * 
 *     if type(filenames) == str:
 *         filenames = (filenames,)             # <<<<<<<<<<<<<<
 *     for filename in filenames:
 *         infile = IOTools.openFile( filename, "r")
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_filenames);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_filenames);
    __Pyx_GIVEREF(__pyx_v_filenames);
    __Pyx_DECREF(__pyx_v_filenames);
    __pyx_v_filenames = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2437
 *     if type(filenames) == str:
 *         filenames = (filenames,)
 *     for filename in filenames:             # <<<<<<<<<<<<<<
 *         infile = IOTools.openFile( filename, "r")
 *         default_name = os.path.basename( filename )
 */
  if (PyList_CheckExact(__pyx_v_filenames) || PyTuple_CheckExact(__pyx_v_filenames)) {
    __pyx_t_3 = __pyx_v_filenames; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_filenames); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_filename);
    __pyx_v_filename = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "GatEngine.pyx":2438
 *         filenames = (filenames,)
 *     for filename in filenames:
 *         infile = IOTools.openFile( filename, "r")             # <<<<<<<<<<<<<<
 *         default_name = os.path.basename( filename )
 *         lineno = 0
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__IOTools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__openFile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__r));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
    __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_infile);
    __pyx_v_infile = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "GatEngine.pyx":2439
 *     for filename in filenames:
 *         infile = IOTools.openFile( filename, "r")
 *         default_name = os.path.basename( filename )             # <<<<<<<<<<<<<<
 *         lineno = 0
 *         try:
 */
    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__basename); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_default_name);
    __pyx_v_default_name = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2440
 *         infile = IOTools.openFile( filename, "r")
 *         default_name = os.path.basename( filename )
 *         lineno = 0             # <<<<<<<<<<<<<<
 *         try:
 *             for bed in bed_iterator( infile ):
 */
    __pyx_v_lineno = 0;

    /* "GatEngine.pyx":2441
 *         default_name = os.path.basename( filename )
 *         lineno = 0
 *         try:             # <<<<<<<<<<<<<<
 *             for bed in bed_iterator( infile ):
 *                 if bed.track:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "GatEngine.pyx":2442
 *         lineno = 0
 *         try:
 *             for bed in bed_iterator( infile ):             # <<<<<<<<<<<<<<
 *                 if bed.track:
 *                     try:
 */
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__bed_iterator); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_infile);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_infile);
        __Pyx_GIVEREF(__pyx_v_infile);
        __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
          __pyx_t_1 = __pyx_t_7; __Pyx_INCREF(__pyx_t_1); __pyx_t_11 = 0;
          __pyx_t_12 = NULL;
        } else {
          __pyx_t_11 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_12 = Py_TYPE(__pyx_t_1)->tp_iternext;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        for (;;) {
          if (!__pyx_t_12 && PyList_CheckExact(__pyx_t_1)) {
            if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_11); __Pyx_INCREF(__pyx_t_7); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            #else
            __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            #endif
          } else if (!__pyx_t_12 && PyTuple_CheckExact(__pyx_t_1)) {
            if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_11); __Pyx_INCREF(__pyx_t_7); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            #else
            __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            #endif
          } else {
            __pyx_t_7 = __pyx_t_12(__pyx_t_1);
            if (unlikely(!__pyx_t_7)) {
              if (PyErr_Occurred()) {
                if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_7);
          }
          if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_9GatEngine_BedProxy))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_XDECREF(((PyObject *)__pyx_v_bed));
          __pyx_v_bed = ((struct __pyx_obj_9GatEngine_BedProxy *)__pyx_t_7);
          __pyx_t_7 = 0;

          /* "GatEngine.pyx":2443
 *         try:
 *             for bed in bed_iterator( infile ):
 *                 if bed.track:             # <<<<<<<<<<<<<<
 *                     try:
 *                         name = bed.track["name"]
 */
          __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_bed->track); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2443; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          if (__pyx_t_4) {

            /* "GatEngine.pyx":2444
 *             for bed in bed_iterator( infile ):
 *                 if bed.track:
 *                     try:             # <<<<<<<<<<<<<<
 *                         name = bed.track["name"]
 *                     except KeyError:
 */
            {
              __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_15);
              /*try:*/ {

                /* "GatEngine.pyx":2445
 *                 if bed.track:
 *                     try:
 *                         name = bed.track["name"]             # <<<<<<<<<<<<<<
 *                     except KeyError:
 *                         raise KeyError( "track without field 'name' in file '%s'" % filename)
 */
                __pyx_t_7 = PyObject_GetItem(__pyx_v_bed->track, ((PyObject *)__pyx_n_s__name)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2445; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_XDECREF(__pyx_v_name);
                __pyx_v_name = __pyx_t_7;
                __pyx_t_7 = 0;
              }
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              goto __pyx_L24_try_end;
              __pyx_L17_error:;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "GatEngine.pyx":2446
 *                     try:
 *                         name = bed.track["name"]
 *                     except KeyError:             # <<<<<<<<<<<<<<
 *                         raise KeyError( "track without field 'name' in file '%s'" % filename)
 *                 elif bed.name:
 */
              __pyx_t_16 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
              if (__pyx_t_16) {
                __Pyx_AddTraceback("GatEngine.readFromBed", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_GOTREF(__pyx_t_17);

                /* "GatEngine.pyx":2447
 *                         name = bed.track["name"]
 *                     except KeyError:
 *                         raise KeyError( "track without field 'name' in file '%s'" % filename)             # <<<<<<<<<<<<<<
 *                 elif bed.name:
 *                     name = bed.name
 */
                __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), __pyx_v_filename); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2447; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
                __Pyx_GOTREF(((PyObject *)__pyx_t_18));
                __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2447; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
                __Pyx_GOTREF(__pyx_t_19);
                PyTuple_SET_ITEM(__pyx_t_19, 0, ((PyObject *)__pyx_t_18));
                __Pyx_GIVEREF(((PyObject *)__pyx_t_18));
                __pyx_t_18 = 0;
                __pyx_t_18 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_19), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2447; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
                __Pyx_GOTREF(__pyx_t_18);
                __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
                __Pyx_Raise(__pyx_t_18, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2447; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                goto __pyx_L18_exception_handled;
              }
              __pyx_L19_except_error:;
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
              goto __pyx_L6_error;
              __pyx_L18_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
              __pyx_L24_try_end:;
            }
            goto __pyx_L16;
          }

          /* "GatEngine.pyx":2448
 *                     except KeyError:
 *                         raise KeyError( "track without field 'name' in file '%s'" % filename)
 *                 elif bed.name:             # <<<<<<<<<<<<<<
 *                     name = bed.name
 *                 else:
 */
          __pyx_t_17 = PyObject_GetAttr(((PyObject *)__pyx_v_bed), __pyx_n_s__name); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2448; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2448; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (__pyx_t_4) {

            /* "GatEngine.pyx":2449
 *                         raise KeyError( "track without field 'name' in file '%s'" % filename)
 *                 elif bed.name:
 *                     name = bed.name             # <<<<<<<<<<<<<<
 *                 else:
 *                     name = default_name
 */
            __pyx_t_17 = PyObject_GetAttr(((PyObject *)__pyx_v_bed), __pyx_n_s__name); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2449; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_XDECREF(__pyx_v_name);
            __pyx_v_name = __pyx_t_17;
            __pyx_t_17 = 0;
            goto __pyx_L16;
          }
          /*else*/ {

            /* "GatEngine.pyx":2451
 *                     name = bed.name
 *                 else:
 *                     name = default_name             # <<<<<<<<<<<<<<
 * 
 *                 if name in tracks:
 */
            __Pyx_INCREF(__pyx_v_default_name);
            __Pyx_XDECREF(__pyx_v_name);
            __pyx_v_name = __pyx_v_default_name;
          }
          __pyx_L16:;

          /* "GatEngine.pyx":2453
 *                     name = default_name
 * 
 *                 if name in tracks:             # <<<<<<<<<<<<<<
 *                     if tracks[name] != filename:
 *                         if allow_multiple:
 */
          __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_v_name, ((PyObject *)__pyx_v_tracks), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2453; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          if (__pyx_t_4) {

            /* "GatEngine.pyx":2454
 * 
 *                 if name in tracks:
 *                     if tracks[name] != filename:             # <<<<<<<<<<<<<<
 *                         if allow_multiple:
 *                             E.warn( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename))
 */
            __pyx_t_17 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_tracks), __pyx_v_name); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2454; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_2 = PyObject_RichCompare(__pyx_t_17, __pyx_v_filename, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2454; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2454; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__pyx_t_4) {

              /* "GatEngine.pyx":2455
 *                 if name in tracks:
 *                     if tracks[name] != filename:
 *                         if allow_multiple:             # <<<<<<<<<<<<<<
 *                             E.warn( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename))
 *                         else:
 */
              __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_allow_multiple); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
              if (__pyx_t_4) {

                /* "GatEngine.pyx":2456
 *                     if tracks[name] != filename:
 *                         if allow_multiple:
 *                             E.warn( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename))             # <<<<<<<<<<<<<<
 *                         else:
 *                             raise ValueError( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename) )
 */
                __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_17 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__warn); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_17);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_tracks), __pyx_v_name); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_INCREF(__pyx_v_name);
                PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_name);
                __Pyx_GIVEREF(__pyx_v_name);
                PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_2);
                __Pyx_INCREF(__pyx_v_filename);
                PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_filename);
                __Pyx_GIVEREF(__pyx_v_filename);
                __pyx_t_2 = 0;
                __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(((PyObject *)__pyx_t_2));
                __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
                __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_2));
                __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
                __pyx_t_2 = 0;
                __pyx_t_2 = PyObject_Call(__pyx_t_17, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                goto __pyx_L29;
              }
              /*else*/ {

                /* "GatEngine.pyx":2458
 *                             E.warn( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename))
 *                         else:
 *                             raise ValueError( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename) )             # <<<<<<<<<<<<<<
 *                         tracks[name] = filename
 *                 else:
 */
                __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_tracks), __pyx_v_name); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_INCREF(__pyx_v_name);
                PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_name);
                __Pyx_GIVEREF(__pyx_v_name);
                PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_2);
                __Pyx_INCREF(__pyx_v_filename);
                PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_filename);
                __Pyx_GIVEREF(__pyx_v_filename);
                __pyx_t_2 = 0;
                __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(((PyObject *)__pyx_t_2));
                __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
                __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_2));
                __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
                __pyx_t_2 = 0;
                __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
                __Pyx_Raise(__pyx_t_2, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
              }
              __pyx_L29:;

              /* "GatEngine.pyx":2459
 *                         else:
 *                             raise ValueError( "track '%s' in multiple filenames: %s and %s" % (name, tracks[name], filename) )
 *                         tracks[name] = filename             # <<<<<<<<<<<<<<
 *                 else:
 *                     tracks[name] = filename
 */
              if (PyDict_SetItem(((PyObject *)__pyx_v_tracks), __pyx_v_name, __pyx_v_filename) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2459; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
              goto __pyx_L28;
            }
            __pyx_L28:;
            goto __pyx_L27;
          }
          /*else*/ {

            /* "GatEngine.pyx":2461
 *                         tracks[name] = filename
 *                 else:
 *                     tracks[name] = filename             # <<<<<<<<<<<<<<
 * 
 *                 l = segment_lists[name][bed.contig]
 */
            if (PyDict_SetItem(((PyObject *)__pyx_v_tracks), __pyx_v_name, __pyx_v_filename) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          }
          __pyx_L27:;

          /* "GatEngine.pyx":2463
 *                     tracks[name] = filename
 * 
 *                 l = segment_lists[name][bed.contig]             # <<<<<<<<<<<<<<
 *                 l.add( atol(bed.fields[1]), atol(bed.fields[2]) )
 *                 lineno += 1
 */
          __pyx_t_2 = PyObject_GetItem(__pyx_v_segment_lists, __pyx_v_name); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2463; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_bed), __pyx_n_s__contig); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2463; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_17 = PyObject_GetItem(__pyx_t_2, __pyx_t_7); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2463; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (!(likely(((__pyx_t_17) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_17, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2463; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_XDECREF(((PyObject *)__pyx_v_l));
          __pyx_v_l = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_17);
          __pyx_t_17 = 0;

          /* "GatEngine.pyx":2464
 * 
 *                 l = segment_lists[name][bed.contig]
 *                 l.add( atol(bed.fields[1]), atol(bed.fields[2]) )             # <<<<<<<<<<<<<<
 *                 lineno += 1
 * 
 */
          __pyx_t_17 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_l->__pyx_vtab)->add(__pyx_v_l, atol((__pyx_v_bed->__pyx_base.fields[1])), atol((__pyx_v_bed->__pyx_base.fields[2])), 0); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "GatEngine.pyx":2465
 *                 l = segment_lists[name][bed.contig]
 *                 l.add( atol(bed.fields[1]), atol(bed.fields[2]) )
 *                 lineno += 1             # <<<<<<<<<<<<<<
 * 
 *         except IOError, msg:
 */
          __pyx_v_lineno = (__pyx_v_lineno + 1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GatEngine.pyx":2467
 *                 lineno += 1
 * 
 *         except IOError, msg:             # <<<<<<<<<<<<<<
 *             raise IOError("malformatted entry in line %s:%i, msg=%s" % (filename,
 *                                                                         lineno,
 */
      __pyx_t_16 = PyErr_ExceptionMatches(__pyx_builtin_IOError);
      if (__pyx_t_16) {
        __Pyx_AddTraceback("GatEngine.readFromBed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_17, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2467; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_17);
        __pyx_v_msg = __pyx_t_17;

        /* "GatEngine.pyx":2469
 *         except IOError, msg:
 *             raise IOError("malformatted entry in line %s:%i, msg=%s" % (filename,
 *                                                                         lineno,             # <<<<<<<<<<<<<<
 *                                                                         msg))
 * 
 */
        __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_lineno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_2);

        /* "GatEngine.pyx":2470
 *             raise IOError("malformatted entry in line %s:%i, msg=%s" % (filename,
 *                                                                         lineno,
 *                                                                         msg))             # <<<<<<<<<<<<<<
 * 
 *     return segment_lists
 */
        __pyx_t_18 = PyTuple_New(3); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_INCREF(__pyx_v_filename);
        PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_filename);
        __Pyx_GIVEREF(__pyx_v_filename);
        PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_msg);
        PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_v_msg);
        __Pyx_GIVEREF(__pyx_v_msg);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_55), ((PyObject *)__pyx_t_18)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L7_exception_handled;
      }
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L7_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_L13_try_end:;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2472
 *                                                                         msg))
 * 
 *     return segment_lists             # <<<<<<<<<<<<<<
 * 
 * ####################################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_segment_lists);
  __pyx_r = __pyx_v_segment_lists;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("GatEngine.readFromBed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_l);
  __Pyx_XDECREF((PyObject *)__pyx_v_bed);
  __Pyx_XDECREF(__pyx_v_segment_lists);
  __Pyx_XDECREF(__pyx_v_tracks);
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XDECREF(__pyx_v_infile);
  __Pyx_XDECREF(__pyx_v_default_name);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_filenames);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_17IntervalContainer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_17IntervalContainer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer___init__(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2483
 *     '''
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.name = None
 *         self.shared_fd = -1
 */

static int __pyx_pf_9GatEngine_17IntervalContainer___init__(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2484
 * 
 *     def __init__(self):
 *         self.name = None             # <<<<<<<<<<<<<<
 *         self.shared_fd = -1
 *         self.shared_fn = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->name));
  __pyx_v_self->name = ((PyObject*)Py_None);

  /* "GatEngine.pyx":2485
 *     def __init__(self):
 *         self.name = None
 *         self.shared_fd = -1             # <<<<<<<<<<<<<<
 *         self.shared_fn = None
 * 
 */
  __pyx_v_self->shared_fd = -1;

  /* "GatEngine.pyx":2486
 *         self.name = None
 *         self.shared_fd = -1
 *         self.shared_fn = None             # <<<<<<<<<<<<<<
 * 
 *     def getName( self ):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->shared_fn);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->shared_fn));
  __pyx_v_self->shared_fn = ((PyObject*)Py_None);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_3getName(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_2getName[] = "IntervalContainer.getName(self)";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_3getName(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getName (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_2getName(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2488
 *         self.shared_fn = None
 * 
 *     def getName( self ):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_2getName(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getName", 0);

  /* "GatEngine.pyx":2489
 * 
 *     def getName( self ):
 *         return self.name             # <<<<<<<<<<<<<<
 * 
 *     def setName( self, name ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->name));
  __pyx_r = ((PyObject *)__pyx_v_self->name);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_5setName(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_4setName[] = "IntervalContainer.setName(self, name)";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_5setName(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("setName (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_4setName(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self), ((PyObject *)__pyx_v_name));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2491
 *         return self.name
 * 
 *     def setName( self, name ):             # <<<<<<<<<<<<<<
 *         self.name = name
 * 
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_4setName(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setName", 0);

  /* "GatEngine.pyx":2492
 * 
 *     def setName( self, name ):
 *         self.name = name             # <<<<<<<<<<<<<<
 * 
 *     def _getSharedMemoryName( self, key = None ):
 */
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_name)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->name));
  __pyx_v_self->name = ((PyObject*)__pyx_v_name);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalContainer.setName", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_7_getSharedMemoryName(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_6_getSharedMemoryName[] = "IntervalContainer._getSharedMemoryName(self, key=None)\nreturn name of shared memory segment.\n\n        If *key* is given that will be used as the suggested name\n        for the memory segment. Otherwise, self.name will be used.\n        \n        Either way, the pid of the process will be added to the name.\n        ";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_7_getSharedMemoryName(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getSharedMemoryName (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,0};
    PyObject* values[1] = {0};

    /* "GatEngine.pyx":2494
 *         self.name = name
 * 
 *     def _getSharedMemoryName( self, key = None ):             # <<<<<<<<<<<<<<
 *         '''return name of shared memory segment.
 * 
 */
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getSharedMemoryName") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_getSharedMemoryName", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalContainer._getSharedMemoryName", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_6_getSharedMemoryName(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self), __pyx_v_key);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_6_getSharedMemoryName(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_getSharedMemoryName", 0);
  __Pyx_INCREF(__pyx_v_key);

  /* "GatEngine.pyx":2502
 *         Either way, the pid of the process will be added to the name.
 *         '''
 *         if key == None:             # <<<<<<<<<<<<<<
 *             assert self.name != None, "IntervalContainer: tried to build shared memory name without name defined"
 *             return "/" + str(os.getpid()) + "_" + self.name
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_key, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "GatEngine.pyx":2503
 *         '''
 *         if key == None:
 *             assert self.name != None, "IntervalContainer: tried to build shared memory name without name defined"             # <<<<<<<<<<<<<<
 *             return "/" + str(os.getpid()) + "_" + self.name
 *         else:
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->name), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) {
      PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_56));
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "GatEngine.pyx":2504
 *         if key == None:
 *             assert self.name != None, "IntervalContainer: tried to build shared memory name without name defined"
 *             return "/" + str(os.getpid()) + "_" + self.name             # <<<<<<<<<<<<<<
 *         else:
 *             if key.startswith("/"): key = key[1:]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getpid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_kp_s_57), __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(__pyx_t_3, ((PyObject *)__pyx_n_s___)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_v_self->name)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":2506
 *             return "/" + str(os.getpid()) + "_" + self.name
 *         else:
 *             if key.startswith("/"): key = key[1:]             # <<<<<<<<<<<<<<
 *             return "/" + str(os.getpid()) + "_" + key
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__startswith); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_58), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {
      __pyx_t_1 = __Pyx_PySequence_GetSlice(__pyx_v_key, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "GatEngine.pyx":2507
 *         else:
 *             if key.startswith("/"): key = key[1:]
 *             return "/" + str(os.getpid()) + "_" + key             # <<<<<<<<<<<<<<
 * 
 *     def share( self, filename = None ):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getpid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_kp_s_57), __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(__pyx_t_3, ((PyObject *)__pyx_n_s___)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_key); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalContainer._getSharedMemoryName", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_9share(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_8share[] = "IntervalContainer.share(self, filename=None)\nsetup collection for sharing.\n        \n        All contents are shared into a single memory mapped\n        file.\n        ";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_9share(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("share (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,0};
    PyObject* values[1] = {0};

    /* "GatEngine.pyx":2509
 *             return "/" + str(os.getpid()) + "_" + key
 * 
 *     def share( self, filename = None ):             # <<<<<<<<<<<<<<
 *         '''setup collection for sharing.
 * 
 */
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "share") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_filename = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("share", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalContainer.share", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_8share(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self), __pyx_v_filename);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_8share(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_filename) {
  off_t __pyx_v_nbytes;
  int __pyx_v_fd;
  int __pyx_v_error;
  void *__pyx_v_mm;
  off_t __pyx_v_offset;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  off_t __pyx_t_4;
  int __pyx_t_5;
  char *__pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("share", 0);
  __Pyx_INCREF(__pyx_v_filename);

  /* "GatEngine.pyx":2516
 *         '''
 *         # determine size off memory required
 *         cdef off_t nbytes = self.counts() * sizeof( Segment )             # <<<<<<<<<<<<<<
 * 
 *         # open file in shared memory
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__counts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(struct __pyx_t_14GatSegmentList_Segment))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyInt_from_py_off_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (off_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_nbytes = __pyx_t_4;

  /* "GatEngine.pyx":2520
 *         # open file in shared memory
 *         cdef int fd
 *         filename = self._getSharedMemoryName( filename )             # <<<<<<<<<<<<<<
 *         assert filename.startswith("/")
 *         fd = shm_open( filename,
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_59); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_filename);
  __pyx_v_filename = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":2521
 *         cdef int fd
 *         filename = self._getSharedMemoryName( filename )
 *         assert filename.startswith("/")             # <<<<<<<<<<<<<<
 *         fd = shm_open( filename,
 *                        O_CREAT | O_RDWR,
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_5)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":2522
 *         filename = self._getSharedMemoryName( filename )
 *         assert filename.startswith("/")
 *         fd = shm_open( filename,             # <<<<<<<<<<<<<<
 *                        O_CREAT | O_RDWR,
 *                        S_IRUSR | S_IWUSR)
 */
  __pyx_t_6 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2524
 *         fd = shm_open( filename,
 *                        O_CREAT | O_RDWR,
 *                        S_IRUSR | S_IWUSR)             # <<<<<<<<<<<<<<
 *         if fd == -1:
 *             error = errno
 */
  __pyx_v_fd = shm_open(__pyx_t_6, (O_CREAT | O_RDWR), (S_IRUSR | S_IWUSR));

  /* "GatEngine.pyx":2525
 *                        O_CREAT | O_RDWR,
 *                        S_IRUSR | S_IWUSR)
 *         if fd == -1:             # <<<<<<<<<<<<<<
 *             error = errno
 *             raise OSError( "could not create shared memory at %s; ERRNO=%i" % (filename, error ))
 */
  __pyx_t_5 = (__pyx_v_fd == -1);
  if (__pyx_t_5) {

    /* "GatEngine.pyx":2526
 *                        S_IRUSR | S_IWUSR)
 *         if fd == -1:
 *             error = errno             # <<<<<<<<<<<<<<
 *             raise OSError( "could not create shared memory at %s; ERRNO=%i" % (filename, error ))
 * 
 */
    __pyx_v_error = errno;

    /* "GatEngine.pyx":2527
 *         if fd == -1:
 *             error = errno
 *             raise OSError( "could not create shared memory at %s; ERRNO=%i" % (filename, error ))             # <<<<<<<<<<<<<<
 * 
 *         # save file descriptor
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_61), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2530
 * 
 *         # save file descriptor
 *         self.shared_fn = filename             # <<<<<<<<<<<<<<
 *         self.shared_fd = fd
 * 
 */
  if (!(likely(PyString_CheckExact(__pyx_v_filename))||((__pyx_v_filename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_filename)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __Pyx_GOTREF(__pyx_v_self->shared_fn);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->shared_fn));
  __pyx_v_self->shared_fn = ((PyObject*)__pyx_v_filename);

  /* "GatEngine.pyx":2531
 *         # save file descriptor
 *         self.shared_fn = filename
 *         self.shared_fd = fd             # <<<<<<<<<<<<<<
 * 
 *         # resize file
 */
  __pyx_v_self->shared_fd = __pyx_v_fd;

  /* "GatEngine.pyx":2534
 * 
 *         # resize file
 *         if ftruncate(fd, nbytes) == -1:             # <<<<<<<<<<<<<<
 *             error = errno
 *             raise OSError( "could not resize memory at %s; ERRNO=%i" % (filename, error) )
 */
  __pyx_t_5 = (ftruncate(__pyx_v_fd, __pyx_v_nbytes) == -1);
  if (__pyx_t_5) {

    /* "GatEngine.pyx":2535
 *         # resize file
 *         if ftruncate(fd, nbytes) == -1:
 *             error = errno             # <<<<<<<<<<<<<<
 *             raise OSError( "could not resize memory at %s; ERRNO=%i" % (filename, error) )
 * 
 */
    __pyx_v_error = errno;

    /* "GatEngine.pyx":2536
 *         if ftruncate(fd, nbytes) == -1:
 *             error = errno
 *             raise OSError( "could not resize memory at %s; ERRNO=%i" % (filename, error) )             # <<<<<<<<<<<<<<
 * 
 *         # setup memory map
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_62), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":2543
 *                   PROT_READ | PROT_WRITE,
 *                   MAP_SHARED,
 *                   fd,             # <<<<<<<<<<<<<<
 *                   0);
 * 
 */
  __pyx_v_mm = mmap(NULL, __pyx_v_nbytes, (PROT_READ | PROT_WRITE), MAP_SHARED, __pyx_v_fd, 0);

  /* "GatEngine.pyx":2546
 *                   0);
 * 
 *         if mm == MAP_FAILED:             # <<<<<<<<<<<<<<
 *             raise ValueError("could not create memory mapped file" )
 * 
 */
  __pyx_t_5 = (__pyx_v_mm == MAP_FAILED);
  if (__pyx_t_5) {

    /* "GatEngine.pyx":2547
 * 
 *         if mm == MAP_FAILED:
 *             raise ValueError("could not create memory mapped file" )             # <<<<<<<<<<<<<<
 * 
 *         # copy all segment lists to shared memory
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_64), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "GatEngine.pyx":2550
 * 
 *         # copy all segment lists to shared memory
 *         cdef off_t offset = 0             # <<<<<<<<<<<<<<
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():
 */
  __pyx_v_offset = 0;

  /* "GatEngine.pyx":2552
 *         cdef off_t offset = 0
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             offset = segmentlist.toMMAP( mm,
 *                                          fd,
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2555
 *             offset = segmentlist.toMMAP( mm,
 *                                          fd,
 *                                          offset )             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_offset = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->toMMAP(__pyx_v_segmentlist, __pyx_v_mm, __pyx_v_fd, __pyx_v_offset);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.share", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_17IntervalContainer_11__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_17IntervalContainer_11__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_17IntervalContainer_10__dealloc__(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":2558
 * 
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 * 
 *         cdef SegmentList segmentlist
 */

static void __pyx_pf_9GatEngine_17IntervalContainer_10__dealloc__(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  int __pyx_v_error;
  PyObject *__pyx_v_fn = NULL;
  int __pyx_v_fd;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  char *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":2563
 *         cdef int error
 * 
 *         if self.shared_fd != -1:             # <<<<<<<<<<<<<<
 *             # if IntervalCollection is destroyed that has
 *             # used memory mapped SegmentLists, the
 */
  __pyx_t_1 = (__pyx_v_self->shared_fd != -1);
  if (__pyx_t_1) {

    /* "GatEngine.pyx":2572
 *             # but necessary if there the SegmentLists are
 *             # referenced outside the IntervalCollection.
 *             for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *                 segmentlist.fromMMAP()
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_3 = __pyx_t_5(__pyx_t_2);
        if (unlikely(!__pyx_t_3)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
      __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "GatEngine.pyx":2573
 *             # referenced outside the IntervalCollection.
 *             for segmentlist in self.getSegmentLists():
 *                 segmentlist.fromMMAP()             # <<<<<<<<<<<<<<
 * 
 *             # disconnect from mmap
 */
      ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->fromMMAP(__pyx_v_segmentlist);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "GatEngine.pyx":2578
 *             # munmap( self.mmap,
 *             #        self.mmap_bytes)
 *             fn = self.shared_fn             # <<<<<<<<<<<<<<
 *             fd = shm_unlink( fn )
 *             error = errno
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->shared_fn);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_fn = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2579
 *             #        self.mmap_bytes)
 *             fn = self.shared_fn
 *             fd = shm_unlink( fn )             # <<<<<<<<<<<<<<
 *             error = errno
 *             if fd == -1:
 */
    __pyx_t_6 = PyBytes_AsString(__pyx_v_fn); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_fd = shm_unlink(__pyx_t_6);

    /* "GatEngine.pyx":2580
 *             fn = self.shared_fn
 *             fd = shm_unlink( fn )
 *             error = errno             # <<<<<<<<<<<<<<
 *             if fd == -1:
 *                 raise OSError( "IntervalCollection.__dealloc__(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn, error ))
 */
    __pyx_v_error = errno;

    /* "GatEngine.pyx":2581
 *             fd = shm_unlink( fn )
 *             error = errno
 *             if fd == -1:             # <<<<<<<<<<<<<<
 *                 raise OSError( "IntervalCollection.__dealloc__(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn, error ))
 *             else:
 */
    __pyx_t_1 = (__pyx_v_fd == -1);
    if (__pyx_t_1) {

      /* "GatEngine.pyx":2582
 *             error = errno
 *             if fd == -1:
 *                 raise OSError( "IntervalCollection.__dealloc__(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn, error ))             # <<<<<<<<<<<<<<
 *             else:
 *                 E.debug( "IntervalCollection.__dealloc__(): freeing shared memory at %s" % self.shared_fn )
 */
      __pyx_t_2 = PyInt_FromLong(__pyx_v_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_self->shared_fn));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->shared_fn));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self->shared_fn));
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_65), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    /*else*/ {

      /* "GatEngine.pyx":2584
 *                 raise OSError( "IntervalCollection.__dealloc__(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn, error ))
 *             else:
 *                 E.debug( "IntervalCollection.__dealloc__(): freeing shared memory at %s" % self.shared_fn )             # <<<<<<<<<<<<<<
 * 
 *     def unshare( self ):
 */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_66), ((PyObject *)__pyx_v_self->shared_fn)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L6:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_fn);
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_13unshare(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_12unshare[] = "IntervalContainer.unshare(self)\nrevert sharing.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_13unshare(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unshare (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_12unshare(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2586
 *                 E.debug( "IntervalCollection.__dealloc__(): freeing shared memory at %s" % self.shared_fn )
 * 
 *     def unshare( self ):             # <<<<<<<<<<<<<<
 *         '''revert sharing.'''
 *         assert self.shared_fd != -1, "unsharing shared IntervalCollection"
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_12unshare(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_v_fn = NULL;
  int __pyx_v_fd;
  int __pyx_v_error;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  char *__pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unshare", 0);

  /* "GatEngine.pyx":2588
 *     def unshare( self ):
 *         '''revert sharing.'''
 *         assert self.shared_fd != -1, "unsharing shared IntervalCollection"             # <<<<<<<<<<<<<<
 *         cdef SegmentList segmentlist
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_self->shared_fd != -1))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_67));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":2591
 *         cdef SegmentList segmentlist
 * 
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             segmentlist.fromMMAP()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2592
 * 
 *         for segmentlist in self.getSegmentLists():
 *             segmentlist.fromMMAP()             # <<<<<<<<<<<<<<
 * 
 *         # disconnect from mmap
 */
    ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->fromMMAP(__pyx_v_segmentlist);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2598
 *         #        self.mmap_bytes)
 * 
 *         fn = self.shared_fn             # <<<<<<<<<<<<<<
 *         fd = shm_unlink( fn )
 *         error = errno
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->shared_fn);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_fn = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":2599
 * 
 *         fn = self.shared_fn
 *         fd = shm_unlink( fn )             # <<<<<<<<<<<<<<
 *         error = errno
 *         if fd == -1:
 */
  __pyx_t_5 = PyBytes_AsString(__pyx_v_fn); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_fd = shm_unlink(__pyx_t_5);

  /* "GatEngine.pyx":2600
 *         fn = self.shared_fn
 *         fd = shm_unlink( fn )
 *         error = errno             # <<<<<<<<<<<<<<
 *         if fd == -1:
 *             raise OSError( "IntervalCollection.unshare(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn,error ))
 */
  __pyx_v_error = errno;

  /* "GatEngine.pyx":2601
 *         fd = shm_unlink( fn )
 *         error = errno
 *         if fd == -1:             # <<<<<<<<<<<<<<
 *             raise OSError( "IntervalCollection.unshare(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn,error ))
 *         else:
 */
  __pyx_t_6 = (__pyx_v_fd == -1);
  if (__pyx_t_6) {

    /* "GatEngine.pyx":2602
 *         error = errno
 *         if fd == -1:
 *             raise OSError( "IntervalCollection.unshare(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn,error ))             # <<<<<<<<<<<<<<
 *         else:
 *             E.debug( "IntervalCollection.unshare(): freeing shared memory at %s" % self.shared_fn )
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->shared_fn));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->shared_fn));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->shared_fn));
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_68), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  /*else*/ {

    /* "GatEngine.pyx":2604
 *             raise OSError( "IntervalCollection.unshare(): could not unlink shared memory %s: ERRNO=%i" % (self.shared_fn,error ))
 *         else:
 *             E.debug( "IntervalCollection.unshare(): freeing shared memory at %s" % self.shared_fn )             # <<<<<<<<<<<<<<
 * 
 *         self.shared_fd = -1
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_69), ((PyObject *)__pyx_v_self->shared_fn)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;

  /* "GatEngine.pyx":2606
 *             E.debug( "IntervalCollection.unshare(): freeing shared memory at %s" % self.shared_fn )
 * 
 *         self.shared_fd = -1             # <<<<<<<<<<<<<<
 * 
 *     def sum( self ):
 */
  __pyx_v_self->shared_fd = -1;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.unshare", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_fn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_15sum(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_14sum[] = "IntervalContainer.sum(self)\nreturn sum of all segment lists.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_15sum(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sum (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_14sum(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2608
 *         self.shared_fd = -1
 * 
 *     def sum( self ):             # <<<<<<<<<<<<<<
 *         '''return sum of all segment lists.'''
 *         cdef SegmentList segmentlist
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_14sum(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sum", 0);

  /* "GatEngine.pyx":2611
 *         '''return sum of all segment lists.'''
 *         cdef SegmentList segmentlist
 *         s = 0             # <<<<<<<<<<<<<<
 *         for segmentlist in self.getSegmentLists():
 *             s += segmentlist.sum()
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_s = __pyx_int_0;

  /* "GatEngine.pyx":2612
 *         cdef SegmentList segmentlist
 *         s = 0
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             s += segmentlist.sum()
 *         return s
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2613
 *         s = 0
 *         for segmentlist in self.getSegmentLists():
 *             s += segmentlist.sum()             # <<<<<<<<<<<<<<
 *         return s
 * 
 */
    __pyx_t_2 = PyLong_FromUnsignedLong(((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->sum(__pyx_v_segmentlist, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2614
 *         for segmentlist in self.getSegmentLists():
 *             s += segmentlist.sum()
 *         return s             # <<<<<<<<<<<<<<
 * 
 *     def counts( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.sum", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_17counts(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_16counts[] = "IntervalContainer.counts(self)\nreturn number of all segments in all segments lists.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_17counts(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("counts (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_16counts(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2616
 *         return s
 * 
 *     def counts( self ):             # <<<<<<<<<<<<<<
 *         '''return number of all segments in all segments lists.'''
 *         cdef SegmentList segmentlist
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_16counts(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("counts", 0);

  /* "GatEngine.pyx":2619
 *         '''return number of all segments in all segments lists.'''
 *         cdef SegmentList segmentlist
 *         s = 0             # <<<<<<<<<<<<<<
 *         for segmentlist in self.getSegmentLists():
 *             s += len(segmentlist)
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_s = __pyx_int_0;

  /* "GatEngine.pyx":2620
 *         cdef SegmentList segmentlist
 *         s = 0
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             s += len(segmentlist)
 *         return s
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2621
 *         s = 0
 *         for segmentlist in self.getSegmentLists():
 *             s += len(segmentlist)             # <<<<<<<<<<<<<<
 *         return s
 * 
 */
    __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_segmentlist)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2622
 *         for segmentlist in self.getSegmentLists():
 *             s += len(segmentlist)
 *         return s             # <<<<<<<<<<<<<<
 * 
 *     def sort( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_19sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_18sort[] = "IntervalContainer.sort(self)\nsort all intervals lists.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_19sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_18sort(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2624
 *         return s
 * 
 *     def sort( self ):             # <<<<<<<<<<<<<<
 *         '''sort all intervals lists.'''
 *         cdef SegmentList segmentlist
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_18sort(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sort", 0);

  /* "GatEngine.pyx":2627
 *         '''sort all intervals lists.'''
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             segmentlist.sort()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __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 = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2628
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():
 *             segmentlist.sort()             # <<<<<<<<<<<<<<
 * 
 *     def extend( self, extension ):
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->sort(__pyx_v_segmentlist, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_21extend(PyObject *__pyx_v_self, PyObject *__pyx_v_extension); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_20extend[] = "IntervalContainer.extend(self, extension)\nextend each interval by a certain amount.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_21extend(PyObject *__pyx_v_self, PyObject *__pyx_v_extension) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extend (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_20extend(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self), ((PyObject *)__pyx_v_extension));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2630
 *             segmentlist.sort()
 * 
 *     def extend( self, extension ):             # <<<<<<<<<<<<<<
 *         '''extend each interval by a certain amount.'''
 *         cdef SegmentList segmentlist
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_20extend(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_extension) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "GatEngine.pyx":2633
 *         '''extend each interval by a certain amount.'''
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             segmentlist.extend_segments( extension )
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2634
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():
 *             segmentlist.extend_segments( extension )             # <<<<<<<<<<<<<<
 * 
 *     def expand( self, expansion ):
 */
    __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_extension); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->extend_segments(__pyx_v_segmentlist, __pyx_t_5, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_23expand(PyObject *__pyx_v_self, PyObject *__pyx_v_expansion); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_22expand[] = "IntervalContainer.expand(self, expansion)\nexpand each interval by a certain amount.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_23expand(PyObject *__pyx_v_self, PyObject *__pyx_v_expansion) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("expand (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_22expand(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self), ((PyObject *)__pyx_v_expansion));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2636
 *             segmentlist.extend_segments( extension )
 * 
 *     def expand( self, expansion ):             # <<<<<<<<<<<<<<
 *         '''expand each interval by a certain amount.'''
 *         cdef SegmentList segmentlist
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_22expand(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self, PyObject *__pyx_v_expansion) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  double __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("expand", 0);

  /* "GatEngine.pyx":2639
 *         '''expand each interval by a certain amount.'''
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             segmentlist.expand_segments( expansion )
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2640
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():
 *             segmentlist.expand_segments( expansion )             # <<<<<<<<<<<<<<
 * 
 *     def normalize( self ):
 */
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_expansion); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->expand_segments(__pyx_v_segmentlist, __pyx_t_5, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.expand", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_25normalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_24normalize[] = "IntervalContainer.normalize(self)\nnormalize all segment lists.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_25normalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("normalize (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_24normalize(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2642
 *             segmentlist.expand_segments( expansion )
 * 
 *     def normalize( self ):             # <<<<<<<<<<<<<<
 *         '''normalize all segment lists.'''
 *         cdef SegmentList segmentlist
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_24normalize(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("normalize", 0);

  /* "GatEngine.pyx":2645
 *         '''normalize all segment lists.'''
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():             # <<<<<<<<<<<<<<
 *             segmentlist.normalize()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getSegmentLists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_segmentlist));
    __pyx_v_segmentlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2646
 *         cdef SegmentList segmentlist
 *         for segmentlist in self.getSegmentLists():
 *             segmentlist.normalize()             # <<<<<<<<<<<<<<
 * 
 *     def check( self ):
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_segmentlist->__pyx_vtab)->normalize(__pyx_v_segmentlist, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.normalize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_27check(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_17IntervalContainer_26check[] = "IntervalContainer.check(self)\ncheck all intervals lists.";
static PyObject *__pyx_pw_9GatEngine_17IntervalContainer_27check(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_17IntervalContainer_26check(((struct __pyx_obj_9GatEngine_IntervalContainer *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2648
 *             segmentlist.normalize()
 * 
 *     def check( self ):             # <<<<<<<<<<<<<<
 *         '''check all intervals lists.'''
 *         self.sort()
 */

static PyObject *__pyx_pf_9GatEngine_17IntervalContainer_26check(struct __pyx_obj_9GatEngine_IntervalContainer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check", 0);

  /* "GatEngine.pyx":2650
 *     def check( self ):
 *         '''check all intervals lists.'''
 *         self.sort()             # <<<<<<<<<<<<<<
 * 
 * #####################################################################
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalContainer.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalDictionary_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalDictionary_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_unreduce = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__unreduce,0};
    PyObject* values[2] = {0,0};

    /* "GatEngine.pyx":2664
 *     '''
 * 
 *     def __init__(self, name = None, unreduce = None ):             # <<<<<<<<<<<<<<
 *         self.intervals = collections.defaultdict( SegmentList )
 *         self.shared_fd = -1
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unreduce);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2664; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_unreduce = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2664; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary___init__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), __pyx_v_name, __pyx_v_unreduce);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9GatEngine_18IntervalDictionary___init__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_unreduce) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2665
 * 
 *     def __init__(self, name = None, unreduce = None ):
 *         self.intervals = collections.defaultdict( SegmentList )             # <<<<<<<<<<<<<<
 *         self.shared_fd = -1
 *         self.name = name
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.intervals);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.intervals);
  __pyx_v_self->__pyx_base.intervals = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2666
 *     def __init__(self, name = None, unreduce = None ):
 *         self.intervals = collections.defaultdict( SegmentList )
 *         self.shared_fd = -1             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.shared_fn = None
 */
  __pyx_v_self->__pyx_base.shared_fd = -1;

  /* "GatEngine.pyx":2667
 *         self.intervals = collections.defaultdict( SegmentList )
 *         self.shared_fd = -1
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.shared_fn = None
 *         if unreduce:
 */
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_name)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  __pyx_v_self->__pyx_base.name = ((PyObject*)__pyx_v_name);

  /* "GatEngine.pyx":2668
 *         self.shared_fd = -1
 *         self.name = name
 *         self.shared_fn = None             # <<<<<<<<<<<<<<
 *         if unreduce:
 *             ( self.name, self.intervals ) = unreduce
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.shared_fn);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.shared_fn));
  __pyx_v_self->__pyx_base.shared_fn = ((PyObject*)Py_None);

  /* "GatEngine.pyx":2669
 *         self.name = name
 *         self.shared_fn = None
 *         if unreduce:             # <<<<<<<<<<<<<<
 *             ( self.name, self.intervals ) = unreduce
 *             # shared_fd and shared_fn remain unset - marks object as slave
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_unreduce); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "GatEngine.pyx":2670
 *         self.shared_fn = None
 *         if unreduce:
 *             ( self.name, self.intervals ) = unreduce             # <<<<<<<<<<<<<<
 *             # shared_fd and shared_fn remain unset - marks object as slave
 * 
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_unreduce))) || (PyList_CheckExact(__pyx_v_unreduce))) {
      PyObject* sequence = __pyx_v_unreduce;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_v_unreduce); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.name));
    __pyx_v_self->__pyx_base.name = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.intervals);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.intervals);
    __pyx_v_self->__pyx_base.intervals = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_2__reduce__[] = "IntervalDictionary.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_2__reduce__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2673
 *             # shared_fd and shared_fn remain unset - marks object as slave
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildIntervalDictionary, (self.name,
 *                                           self.intervals ))
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_2__reduce__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":2674
 * 
 *     def __reduce__(self):
 *         return (buildIntervalDictionary, (self.name,             # <<<<<<<<<<<<<<
 *                                           self.intervals ))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_70); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "GatEngine.pyx":2675
 *     def __reduce__(self):
 *         return (buildIntervalDictionary, (self.name,
 *                                           self.intervals ))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.intervals);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->__pyx_base.intervals);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.intervals);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9GatEngine_18IntervalDictionary_6generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_5getSegmentLists(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_4getSegmentLists[] = "IntervalDictionary.getSegmentLists(self)\nyield all segment lists.";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_5getSegmentLists(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getSegmentLists (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_4getSegmentLists(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2678
 * 
 * 
 *     def getSegmentLists( self ):             # <<<<<<<<<<<<<<
 *         '''yield all segment lists.'''
 *         for contig, segmentlist in self.intervals.iteritems():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_4getSegmentLists(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getSegmentLists", 0);
  __pyx_cur_scope = (struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *)__pyx_ptype_9GatEngine___pyx_scope_struct_1_getSegmentLists->tp_new(__pyx_ptype_9GatEngine___pyx_scope_struct_1_getSegmentLists, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_9GatEngine_18IntervalDictionary_6generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.getSegmentLists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9GatEngine_18IntervalDictionary_6generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *__pyx_cur_scope = ((struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2680
 *     def getSegmentLists( self ):
 *         '''yield all segment lists.'''
 *         for contig, segmentlist in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             yield segmentlist
 * 
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_cur_scope->__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_contig);
    __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_contig);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_cur_scope->__pyx_v_contig = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_segmentlist);
    __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_segmentlist);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2681
 *         '''yield all segment lists.'''
 *         for contig, segmentlist in self.intervals.iteritems():
 *             yield segmentlist             # <<<<<<<<<<<<<<
 * 
 *     def intersect( self, other ):
 */
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_segmentlist);
    __pyx_r = __pyx_cur_scope->__pyx_v_segmentlist;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("getSegmentLists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Generator_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return NULL;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_8intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_7intersect[] = "IntervalDictionary.intersect(self, other)\nintersect with intervals in other.";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_8intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("intersect (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_7intersect(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_other));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2683
 *             yield segmentlist
 * 
 *     def intersect( self, other ):             # <<<<<<<<<<<<<<
 *         '''intersect with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_7intersect(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("intersect", 0);

  /* "GatEngine.pyx":2685
 *     def intersect( self, other ):
 *         '''intersect with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():             # <<<<<<<<<<<<<<
 *             if contig in other:
 *                 segmentlist.intersect( other[contig] )
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_contig);
    __pyx_v_contig = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_segmentlist);
    __pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2686
 *         '''intersect with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():
 *             if contig in other:             # <<<<<<<<<<<<<<
 *                 segmentlist.intersect( other[contig] )
 *             else:
 */
    __pyx_t_9 = (__Pyx_PySequence_Contains(__pyx_v_contig, __pyx_v_other, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_9) {

      /* "GatEngine.pyx":2687
 *         for contig, segmentlist in self.intervals.items():
 *             if contig in other:
 *                 segmentlist.intersect( other[contig] )             # <<<<<<<<<<<<<<
 *             else:
 *                 del self.intervals[contig]
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__intersect); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyObject_GetItem(__pyx_v_other, __pyx_v_contig); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "GatEngine.pyx":2689
 *                 segmentlist.intersect( other[contig] )
 *             else:
 *                 del self.intervals[contig]             # <<<<<<<<<<<<<<
 * 
 *     def truncate( self, other ):
 */
      if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2689; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_10truncate(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_9truncate[] = "IntervalDictionary.truncate(self, other)\ntruncate intervals with intervals in other.";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_10truncate(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("truncate (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_9truncate(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_other));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2691
 *                 del self.intervals[contig]
 * 
 *     def truncate( self, other ):             # <<<<<<<<<<<<<<
 *         '''truncate intervals with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_9truncate(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("truncate", 0);

  /* "GatEngine.pyx":2693
 *     def truncate( self, other ):
 *         '''truncate intervals with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():             # <<<<<<<<<<<<<<
 *             if contig in other:
 *                 segmentlist.truncate( other[contig] )
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_contig);
    __pyx_v_contig = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_segmentlist);
    __pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2694
 *         '''truncate intervals with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():
 *             if contig in other:             # <<<<<<<<<<<<<<
 *                 segmentlist.truncate( other[contig] )
 *             else:
 */
    __pyx_t_9 = (__Pyx_PySequence_Contains(__pyx_v_contig, __pyx_v_other, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_9) {

      /* "GatEngine.pyx":2695
 *         for contig, segmentlist in self.intervals.items():
 *             if contig in other:
 *                 segmentlist.truncate( other[contig] )             # <<<<<<<<<<<<<<
 *             else:
 *                 del self.intervals[contig]
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__truncate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyObject_GetItem(__pyx_v_other, __pyx_v_contig); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "GatEngine.pyx":2697
 *                 segmentlist.truncate( other[contig] )
 *             else:
 *                 del self.intervals[contig]             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self): return len(self.intervals)
 */
      if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.truncate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static Py_ssize_t __pyx_pw_9GatEngine_18IntervalDictionary_12__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_9GatEngine_18IntervalDictionary_12__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_11__len__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2699
 *                 del self.intervals[contig]
 * 
 *     def __len__(self): return len(self.intervals)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */

static Py_ssize_t __pyx_pf_9GatEngine_18IntervalDictionary_11__len__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);
  __pyx_t_1 = __pyx_v_self->__pyx_base.intervals;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_14__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_14__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_13__str__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2701
 *     def __len__(self): return len(self.intervals)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return ";".join( ["%s:%i,%i" % (x, len(y), y.sum()) for x,y in self.intervals.items()])
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_13__str__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "GatEngine.pyx":2702
 * 
 *     def __str__(self):
 *         return ";".join( ["%s:%i,%i" % (x, len(y), y.sum()) for x,y in self.intervals.items()])             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self,key): del self.intervals[key]
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_71), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_4 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_7;
    __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_v_y);
    __pyx_v_y = __pyx_t_8;
    __pyx_t_8 = 0;
    __pyx_t_11 = PyObject_Length(__pyx_v_y); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyObject_GetAttr(__pyx_v_y, __pyx_n_s__sum); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_x);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_x);
    __Pyx_GIVEREF(__pyx_v_x);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_4 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_72), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (unlikely(__Pyx_PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalDictionary_16__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalDictionary_16__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_15__delitem__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2704
 *         return ";".join( ["%s:%i,%i" % (x, len(y), y.sum()) for x,y in self.intervals.items()])
 * 
 *     def __delitem__(self,key): del self.intervals[key]             # <<<<<<<<<<<<<<
 * 
 *     def keys(self): return self.intervals.keys()
 */

static int __pyx_pf_9GatEngine_18IntervalDictionary_15__delitem__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delitem__", 0);
  if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_18keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_17keys[] = "IntervalDictionary.keys(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_18keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_17keys(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2706
 *     def __delitem__(self,key): del self.intervals[key]
 * 
 *     def keys(self): return self.intervals.keys()             # <<<<<<<<<<<<<<
 * 
 *     def add( self, contig, segmentlist ):
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_17keys(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_20add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_19add[] = "IntervalDictionary.add(self, contig, segmentlist)";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_20add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__contig,&__pyx_n_s__segmentlist,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__contig)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segmentlist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_contig = values[0];
    __pyx_v_segmentlist = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_19add(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), __pyx_v_contig, __pyx_v_segmentlist);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2708
 *     def keys(self): return self.intervals.keys()
 * 
 *     def add( self, contig, segmentlist ):             # <<<<<<<<<<<<<<
 *         self.intervals[contig] = segmentlist
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_19add(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_segmentlist) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);

  /* "GatEngine.pyx":2709
 * 
 *     def add( self, contig, segmentlist ):
 *         self.intervals[contig] = segmentlist             # <<<<<<<<<<<<<<
 * 
 *     def items(self ):
 */
  if (PyObject_SetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_contig, __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_22items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_21items[] = "IntervalDictionary.items(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_22items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_21items(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2711
 *         self.intervals[contig] = segmentlist
 * 
 *     def items(self ):             # <<<<<<<<<<<<<<
 *         return self.intervals.items()
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_21items(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("items", 0);

  /* "GatEngine.pyx":2712
 * 
 *     def items(self ):
 *         return self.intervals.items()             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_24__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_24__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_23__getitem__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2714
 *         return self.intervals.items()
 * 
 *     def __getitem__(self, key ):             # <<<<<<<<<<<<<<
 *         return self.intervals[key]
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_23__getitem__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "GatEngine.pyx":2715
 * 
 *     def __getitem__(self, key ):
 *         return self.intervals[key]             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, key, val ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalDictionary_26__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalDictionary_26__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_25__setitem__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_key), ((PyObject *)__pyx_v_val));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2717
 *         return self.intervals[key]
 * 
 *     def __setitem__(self, key, val ):             # <<<<<<<<<<<<<<
 *         self.intervals[key] = val
 * 
 */

static int __pyx_pf_9GatEngine_18IntervalDictionary_25__setitem__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "GatEngine.pyx":2718
 * 
 *     def __setitem__(self, key, val ):
 *         self.intervals[key] = val             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key ):
 */
  if (PyObject_SetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_key, __pyx_v_val) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalDictionary_28__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalDictionary_28__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_27__contains__(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2720
 *         self.intervals[key] = val
 * 
 *     def __contains__(self, key ):             # <<<<<<<<<<<<<<
 *         return key in self.intervals
 * 
 */

static int __pyx_pf_9GatEngine_18IntervalDictionary_27__contains__(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "GatEngine.pyx":2721
 * 
 *     def __contains__(self, key ):
 *         return key in self.intervals             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
  __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_v_self->__pyx_base.intervals, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_30iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_29iteritems[] = "IntervalDictionary.iteritems(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_30iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_29iteritems(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2723
 *         return key in self.intervals
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         return self.intervals.iteritems()
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_29iteritems(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iteritems", 0);

  /* "GatEngine.pyx":2724
 * 
 *     def iteritems(self):
 *         return self.intervals.iteritems()             # <<<<<<<<<<<<<<
 * 
 *     def clone( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__iteritems); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_32clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_31clone[] = "IntervalDictionary.clone(self)\nreturn a copy of the data.";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_32clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clone (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_31clone(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2726
 *         return self.intervals.iteritems()
 * 
 *     def clone( self ):             # <<<<<<<<<<<<<<
 *         '''return a copy of the data.'''
 *         r = IntervalDictionary()
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_31clone(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_r = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clone", 0);

  /* "GatEngine.pyx":2728
 *     def clone( self ):
 *         '''return a copy of the data.'''
 *         r = IntervalDictionary()             # <<<<<<<<<<<<<<
 *         for contig, segmentlist in self.intervals.iteritems():
 *             r[contig] = SegmentList( clone = segmentlist )
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_r = ((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":2729
 *         '''return a copy of the data.'''
 *         r = IntervalDictionary()
 *         for contig, segmentlist in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             r[contig] = SegmentList( clone = segmentlist )
 *         return r
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_contig);
    __pyx_v_contig = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_segmentlist);
    __pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2730
 *         r = IntervalDictionary()
 *         for contig, segmentlist in self.intervals.iteritems():
 *             r[contig] = SegmentList( clone = segmentlist )             # <<<<<<<<<<<<<<
 *         return r
 * 
 */
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__clone), __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (PyObject_SetItem(((PyObject *)__pyx_v_r), __pyx_v_contig, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2731
 *         for contig, segmentlist in self.intervals.iteritems():
 *             r[contig] = SegmentList( clone = segmentlist )
 *         return r             # <<<<<<<<<<<<<<
 * 
 *     def filter( self, other ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_r));
  __pyx_r = ((PyObject *)__pyx_v_r);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_34filter(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_33filter[] = "IntervalDictionary.filter(self, other)\nremove all intervals not overlapping with intervals in other.";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_34filter(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_33filter(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), ((PyObject *)__pyx_v_other));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2733
 *         return r
 * 
 *     def filter( self, other ):             # <<<<<<<<<<<<<<
 *         '''remove all intervals not overlapping with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_33filter(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("filter", 0);

  /* "GatEngine.pyx":2735
 *     def filter( self, other ):
 *         '''remove all intervals not overlapping with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():             # <<<<<<<<<<<<<<
 *             if contig in other:
 *                 segmentlist.filter( other[contig] )
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_contig);
    __pyx_v_contig = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_segmentlist);
    __pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2736
 *         '''remove all intervals not overlapping with intervals in other.'''
 *         for contig, segmentlist in self.intervals.items():
 *             if contig in other:             # <<<<<<<<<<<<<<
 *                 segmentlist.filter( other[contig] )
 *             else:
 */
    __pyx_t_9 = (__Pyx_PySequence_Contains(__pyx_v_contig, __pyx_v_other, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_9) {

      /* "GatEngine.pyx":2737
 *         for contig, segmentlist in self.intervals.items():
 *             if contig in other:
 *                 segmentlist.filter( other[contig] )             # <<<<<<<<<<<<<<
 *             else:
 *                 del self.intervals[contig]
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyObject_GetItem(__pyx_v_other, __pyx_v_contig); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "GatEngine.pyx":2739
 *                 segmentlist.filter( other[contig] )
 *             else:
 *                 del self.intervals[contig]             # <<<<<<<<<<<<<<
 * 
 *     def toIsochores( self, isochores, truncate = False ):
 */
      if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_36toIsochores(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_35toIsochores[] = "IntervalDictionary.toIsochores(self, isochores, truncate=False)\nsplit per-contig segmentlists into per-isochore segmentlist.\n\n        If *truncate* is given, the segments are truncated at isochore\n        boundaries.\n\n        The IntervalDictionary is modified in-place.\n        ";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_36toIsochores(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_isochores = 0;
  PyObject *__pyx_v_truncate = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("toIsochores (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__isochores,&__pyx_n_s__truncate,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k_73;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochores)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__truncate);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "toIsochores") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_isochores = values[0];
    __pyx_v_truncate = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("toIsochores", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.toIsochores", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_35toIsochores(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self), __pyx_v_isochores, __pyx_v_truncate);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2741
 *                 del self.intervals[contig]
 * 
 *     def toIsochores( self, isochores, truncate = False ):             # <<<<<<<<<<<<<<
 *         '''split per-contig segmentlists into per-isochore segmentlist.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_35toIsochores(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self, PyObject *__pyx_v_isochores, PyObject *__pyx_v_truncate) {
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_v_other_track = NULL;
  PyObject *__pyx_v_other_vv = NULL;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_newlist = NULL;
  PyObject *__pyx_v_isochore = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("toIsochores", 0);

  /* "GatEngine.pyx":2749
 *         The IntervalDictionary is modified in-place.
 *         '''
 *         for contig, segmentlist in self.intervals.items():             # <<<<<<<<<<<<<<
 *             for other_track, other_vv in isochores.iteritems():
 *                 newlist = SegmentList( clone = segmentlist )
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_contig);
    __pyx_v_contig = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_segmentlist);
    __pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2750
 *         '''
 *         for contig, segmentlist in self.intervals.items():
 *             for other_track, other_vv in isochores.iteritems():             # <<<<<<<<<<<<<<
 *                 newlist = SegmentList( clone = segmentlist )
 *                 if truncate:
 */
    __pyx_t_9 = 0;
    if (unlikely(__pyx_v_isochores == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_isochores, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_10), (&__pyx_t_11)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_6;
    __pyx_t_6 = 0;
    while (1) {
      __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_10, &__pyx_t_9, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_11);
      if (unlikely(__pyx_t_12 == 0)) break;
      if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_v_other_track);
      __pyx_v_other_track = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_other_vv);
      __pyx_v_other_vv = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "GatEngine.pyx":2751
 *         for contig, segmentlist in self.intervals.items():
 *             for other_track, other_vv in isochores.iteritems():
 *                 newlist = SegmentList( clone = segmentlist )             # <<<<<<<<<<<<<<
 *                 if truncate:
 *                     newlist.intersect( other_vv[contig] )
 */
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__clone), __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_XDECREF(((PyObject *)__pyx_v_newlist));
      __pyx_v_newlist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "GatEngine.pyx":2752
 *             for other_track, other_vv in isochores.iteritems():
 *                 newlist = SegmentList( clone = segmentlist )
 *                 if truncate:             # <<<<<<<<<<<<<<
 *                     newlist.intersect( other_vv[contig] )
 *                 else:
 */
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_truncate); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_13) {

        /* "GatEngine.pyx":2753
 *                 newlist = SegmentList( clone = segmentlist )
 *                 if truncate:
 *                     newlist.intersect( other_vv[contig] )             # <<<<<<<<<<<<<<
 *                 else:
 *                     newlist.filter( other_vv[contig] )
 */
        __pyx_t_6 = PyObject_GetItem(__pyx_v_other_vv, __pyx_v_contig); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_newlist->__pyx_vtab)->intersect(__pyx_v_newlist, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_6), 0)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "GatEngine.pyx":2755
 *                     newlist.intersect( other_vv[contig] )
 *                 else:
 *                     newlist.filter( other_vv[contig] )             # <<<<<<<<<<<<<<
 *                 isochore = "%s.%s" % (contig, other_track)
 *                 self.intervals[isochore] = newlist
 */
        __pyx_t_5 = PyObject_GetItem(__pyx_v_other_vv, __pyx_v_contig); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_14GatSegmentList_SegmentList *)__pyx_v_newlist->__pyx_vtab)->filter(__pyx_v_newlist, ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_5), 0)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __pyx_L9:;

      /* "GatEngine.pyx":2756
 *                 else:
 *                     newlist.filter( other_vv[contig] )
 *                 isochore = "%s.%s" % (contig, other_track)             # <<<<<<<<<<<<<<
 *                 self.intervals[isochore] = newlist
 *             del self.intervals[contig]
 */
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_contig);
      __Pyx_GIVEREF(__pyx_v_contig);
      __Pyx_INCREF(__pyx_v_other_track);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_other_track);
      __Pyx_GIVEREF(__pyx_v_other_track);
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_74), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_isochore);
      __pyx_v_isochore = ((PyObject *)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "GatEngine.pyx":2757
 *                     newlist.filter( other_vv[contig] )
 *                 isochore = "%s.%s" % (contig, other_track)
 *                 self.intervals[isochore] = newlist             # <<<<<<<<<<<<<<
 *             del self.intervals[contig]
 * 
 */
      if (PyObject_SetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_isochore, ((PyObject *)__pyx_v_newlist)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "GatEngine.pyx":2758
 *                 isochore = "%s.%s" % (contig, other_track)
 *                 self.intervals[isochore] = newlist
 *             del self.intervals[contig]             # <<<<<<<<<<<<<<
 * 
 *     def fromIsochores( self ):
 */
    if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2758; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.toIsochores", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_other_track);
  __Pyx_XDECREF(__pyx_v_other_vv);
  __Pyx_XDECREF((PyObject *)__pyx_v_newlist);
  __Pyx_XDECREF(__pyx_v_isochore);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_38fromIsochores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalDictionary_37fromIsochores[] = "IntervalDictionary.fromIsochores(self)\nmerge isochores into contigs";
static PyObject *__pyx_pw_9GatEngine_18IntervalDictionary_38fromIsochores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromIsochores (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalDictionary_37fromIsochores(((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2760
 *             del self.intervals[contig]
 * 
 *     def fromIsochores( self ):             # <<<<<<<<<<<<<<
 *         '''merge isochores into contigs'''
 *         new = collections.defaultdict( SegmentList )
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalDictionary_37fromIsochores(struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_self) {
  PyObject *__pyx_v_new = NULL;
  int __pyx_v_normalize;
  PyObject *__pyx_v_isochore = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_v_contig = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_iso = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromIsochores", 0);

  /* "GatEngine.pyx":2762
 *     def fromIsochores( self ):
 *         '''merge isochores into contigs'''
 *         new = collections.defaultdict( SegmentList )             # <<<<<<<<<<<<<<
 *         normalize = False
 *         # isochores might or might not be present
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_new = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2763
 *         '''merge isochores into contigs'''
 *         new = collections.defaultdict( SegmentList )
 *         normalize = False             # <<<<<<<<<<<<<<
 *         # isochores might or might not be present
 *         for isochore, segmentlist in self.intervals.items():
 */
  __pyx_v_normalize = 0;

  /* "GatEngine.pyx":2765
 *         normalize = False
 *         # isochores might or might not be present
 *         for isochore, segmentlist in self.intervals.items():             # <<<<<<<<<<<<<<
 *             if "." in isochore:
 *                 contig, iso = isochore.split(".")
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__items); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_isochore);
    __pyx_v_isochore = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_v_segmentlist);
    __pyx_v_segmentlist = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2766
 *         # isochores might or might not be present
 *         for isochore, segmentlist in self.intervals.items():
 *             if "." in isochore:             # <<<<<<<<<<<<<<
 *                 contig, iso = isochore.split(".")
 *                 new[contig].extend( segmentlist )
 */
    __pyx_t_9 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_kp_s_75), __pyx_v_isochore, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_9) {

      /* "GatEngine.pyx":2767
 *         for isochore, segmentlist in self.intervals.items():
 *             if "." in isochore:
 *                 contig, iso = isochore.split(".")             # <<<<<<<<<<<<<<
 *                 new[contig].extend( segmentlist )
 *                 normalize = True
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_isochore, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_76), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
        PyObject* sequence = __pyx_t_6;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
        index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 1; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_v_iso);
      __pyx_v_iso = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "GatEngine.pyx":2768
 *             if "." in isochore:
 *                 contig, iso = isochore.split(".")
 *                 new[contig].extend( segmentlist )             # <<<<<<<<<<<<<<
 *                 normalize = True
 *             else:
 */
      __pyx_t_6 = PyObject_GetItem(__pyx_v_new, __pyx_v_contig); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__extend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_segmentlist);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_segmentlist);
      __Pyx_GIVEREF(__pyx_v_segmentlist);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GatEngine.pyx":2769
 *                 contig, iso = isochore.split(".")
 *                 new[contig].extend( segmentlist )
 *                 normalize = True             # <<<<<<<<<<<<<<
 *             else:
 *                 new[isochore] = segmentlist
 */
      __pyx_v_normalize = 1;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "GatEngine.pyx":2771
 *                 normalize = True
 *             else:
 *                 new[isochore] = segmentlist             # <<<<<<<<<<<<<<
 * 
 *         if normalize:
 */
      if (PyObject_SetItem(__pyx_v_new, __pyx_v_isochore, __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2773
 *                 new[isochore] = segmentlist
 * 
 *         if normalize:             # <<<<<<<<<<<<<<
 *             # merge adjacent intervals (and normalize)
 *             for x in new.values():
 */
  if (__pyx_v_normalize) {

    /* "GatEngine.pyx":2775
 *         if normalize:
 *             # merge adjacent intervals (and normalize)
 *             for x in new.values():             # <<<<<<<<<<<<<<
 *                 x.merge( 0 )
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_new, __pyx_n_s__values); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_5(__pyx_t_3);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "GatEngine.pyx":2776
 *             # merge adjacent intervals (and normalize)
 *             for x in new.values():
 *                 x.merge( 0 )             # <<<<<<<<<<<<<<
 * 
 *         self.intervals = new
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__merge); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_77), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "GatEngine.pyx":2778
 *                 x.merge( 0 )
 * 
 *         self.intervals = new             # <<<<<<<<<<<<<<
 * 
 * def buildIntervalDictionary( *args ):
 */
  __Pyx_INCREF(__pyx_v_new);
  __Pyx_GIVEREF(__pyx_v_new);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.intervals);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.intervals);
  __pyx_v_self->__pyx_base.intervals = __pyx_v_new;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("GatEngine.IntervalDictionary.fromIsochores", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_new);
  __Pyx_XDECREF(__pyx_v_isochore);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_iso);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_37buildIntervalDictionary(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_36buildIntervalDictionary[] = "buildIntervalDictionary(*args)\nunpickling - return a rebuilt SamplerShift object.";
static PyMethodDef __pyx_mdef_9GatEngine_37buildIntervalDictionary = {__Pyx_NAMESTR("buildIntervalDictionary"), (PyCFunction)__pyx_pw_9GatEngine_37buildIntervalDictionary, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_36buildIntervalDictionary)};
static PyObject *__pyx_pw_9GatEngine_37buildIntervalDictionary(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildIntervalDictionary (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildIntervalDictionary", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_36buildIntervalDictionary(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2780
 *         self.intervals = new
 * 
 * def buildIntervalDictionary( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )
 */

static PyObject *__pyx_pf_9GatEngine_36buildIntervalDictionary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildIntervalDictionary", 0);

  /* "GatEngine.pyx":2782
 * def buildIntervalDictionary( *args ):
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )             # <<<<<<<<<<<<<<
 * 
 * #####################################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__unreduce), ((PyObject *)__pyx_v_args)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalCollection)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildIntervalDictionary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalCollection_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalCollection_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_unreduce = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__unreduce,0};
    PyObject* values[2] = {0,0};

    /* "GatEngine.pyx":2797
 * 
 * 
 *     def __init__(self, name = None, unreduce = None ):             # <<<<<<<<<<<<<<
 *         self.intervals = collections.defaultdict( IntervalDictionary )
 *         self.name = name
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unreduce);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_name = values[0];
    __pyx_v_unreduce = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection___init__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_name, __pyx_v_unreduce);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9GatEngine_18IntervalCollection___init__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_unreduce) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":2798
 * 
 *     def __init__(self, name = None, unreduce = None ):
 *         self.intervals = collections.defaultdict( IntervalDictionary )             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.shared_fd = -1
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.intervals);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.intervals);
  __pyx_v_self->__pyx_base.intervals = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2799
 *     def __init__(self, name = None, unreduce = None ):
 *         self.intervals = collections.defaultdict( IntervalDictionary )
 *         self.name = name             # <<<<<<<<<<<<<<
 *         self.shared_fd = -1
 *         self.shared_fn = None
 */
  if (!(likely(PyString_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_name)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  __pyx_v_self->__pyx_base.name = ((PyObject*)__pyx_v_name);

  /* "GatEngine.pyx":2800
 *         self.intervals = collections.defaultdict( IntervalDictionary )
 *         self.name = name
 *         self.shared_fd = -1             # <<<<<<<<<<<<<<
 *         self.shared_fn = None
 *         if unreduce:
 */
  __pyx_v_self->__pyx_base.shared_fd = -1;

  /* "GatEngine.pyx":2801
 *         self.name = name
 *         self.shared_fd = -1
 *         self.shared_fn = None             # <<<<<<<<<<<<<<
 *         if unreduce:
 *             ( self.name, self.intervals ) = unreduce
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.shared_fn);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.shared_fn));
  __pyx_v_self->__pyx_base.shared_fn = ((PyObject*)Py_None);

  /* "GatEngine.pyx":2802
 *         self.shared_fd = -1
 *         self.shared_fn = None
 *         if unreduce:             # <<<<<<<<<<<<<<
 *             ( self.name, self.intervals ) = unreduce
 *             # shared_fd and shared_fn remain unset - marks object as slave
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_unreduce); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "GatEngine.pyx":2803
 *         self.shared_fn = None
 *         if unreduce:
 *             ( self.name, self.intervals ) = unreduce             # <<<<<<<<<<<<<<
 *             # shared_fd and shared_fn remain unset - marks object as slave
 * 
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_unreduce))) || (PyList_CheckExact(__pyx_v_unreduce))) {
      PyObject* sequence = __pyx_v_unreduce;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_v_unreduce); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.name));
    __pyx_v_self->__pyx_base.name = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.intervals);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.intervals);
    __pyx_v_self->__pyx_base.intervals = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_2__reduce__[] = "IntervalCollection.__reduce__(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_2__reduce__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2806
 *             # shared_fd and shared_fn remain unset - marks object as slave
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (buildIntervalCollection, (self.name,
 *                                           self.intervals ))
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_2__reduce__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "GatEngine.pyx":2807
 * 
 *     def __reduce__(self):
 *         return (buildIntervalCollection, (self.name,             # <<<<<<<<<<<<<<
 *                                           self.intervals ))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_78); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "GatEngine.pyx":2808
 *     def __reduce__(self):
 *         return (buildIntervalCollection, (self.name,
 *                                           self.intervals ))             # <<<<<<<<<<<<<<
 * 
 *     def getSegmentLists( self ):
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.intervals);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->__pyx_base.intervals);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.intervals);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9GatEngine_18IntervalCollection_6generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_5getSegmentLists(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_4getSegmentLists[] = "IntervalCollection.getSegmentLists(self)\nyield all segment lists.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_5getSegmentLists(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getSegmentLists (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_4getSegmentLists(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2810
 *                                           self.intervals ))
 * 
 *     def getSegmentLists( self ):             # <<<<<<<<<<<<<<
 *         '''yield all segment lists.'''
 *         for track,v in self.intervals.iteritems():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_4getSegmentLists(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getSegmentLists", 0);
  __pyx_cur_scope = (struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *)__pyx_ptype_9GatEngine___pyx_scope_struct_2_getSegmentLists->tp_new(__pyx_ptype_9GatEngine___pyx_scope_struct_2_getSegmentLists, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_9GatEngine_18IntervalCollection_6generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.getSegmentLists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9GatEngine_18IntervalCollection_6generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *__pyx_cur_scope = ((struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2812
 *     def getSegmentLists( self ):
 *         '''yield all segment lists.'''
 *         for track,v in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in v.iteritems():
 *                 yield segmentlist
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_cur_scope->__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_track);
    __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_track);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_cur_scope->__pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_v = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2813
 *         '''yield all segment lists.'''
 *         for track,v in self.intervals.iteritems():
 *             for contig, segmentlist in v.iteritems():             # <<<<<<<<<<<<<<
 *                 yield segmentlist
 * 
 */
    __pyx_t_8 = 0;
    if (unlikely(__pyx_cur_scope->__pyx_v_v == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_v, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_9), (&__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_5;
    __pyx_t_5 = 0;
    while (1) {
      __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_8, &__pyx_t_5, &__pyx_t_10, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_11 == 0)) break;
      if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_contig);
      __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_contig);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_contig = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_segmentlist);
      __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_segmentlist);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_cur_scope->__pyx_v_segmentlist = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "GatEngine.pyx":2814
 *         for track,v in self.intervals.iteritems():
 *             for contig, segmentlist in v.iteritems():
 *                 yield segmentlist             # <<<<<<<<<<<<<<
 * 
 *     def load( self, filenames, split_tracks = False ):
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_segmentlist);
      __pyx_r = __pyx_cur_scope->__pyx_v_segmentlist;
      __Pyx_XGIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
      __Pyx_XGIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
      __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
      __pyx_cur_scope->__pyx_t_6 = __pyx_t_8;
      __pyx_cur_scope->__pyx_t_7 = __pyx_t_9;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L8_resume_from_yield:;
      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_1);
      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
      __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
      __pyx_cur_scope->__pyx_t_4 = 0;
      __Pyx_XGOTREF(__pyx_t_6);
      __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
      __pyx_t_8 = __pyx_cur_scope->__pyx_t_6;
      __pyx_t_9 = __pyx_cur_scope->__pyx_t_7;
      if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("getSegmentLists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Generator_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return NULL;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_8load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_7load[] = "IntervalCollection.load(self, filenames, split_tracks=False)\nload segments from filenames and pre-process them.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_8load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filenames = 0;
  PyObject *__pyx_v_split_tracks = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filenames,&__pyx_n_s__split_tracks,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k_79;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filenames)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__split_tracks);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "load") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_filenames = values[0];
    __pyx_v_split_tracks = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("load", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_7load(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_filenames, __pyx_v_split_tracks);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2816
 *                 yield segmentlist
 * 
 *     def load( self, filenames, split_tracks = False ):             # <<<<<<<<<<<<<<
 *         '''load segments from filenames and pre-process them.'''
 *         self.intervals = readFromBed( filenames, split_tracks )
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_7load(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_filenames, PyObject *__pyx_v_split_tracks) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load", 0);

  /* "GatEngine.pyx":2818
 *     def load( self, filenames, split_tracks = False ):
 *         '''load segments from filenames and pre-process them.'''
 *         self.intervals = readFromBed( filenames, split_tracks )             # <<<<<<<<<<<<<<
 *         self.normalize()
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__readFromBed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_filenames);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filenames);
  __Pyx_GIVEREF(__pyx_v_filenames);
  __Pyx_INCREF(__pyx_v_split_tracks);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_split_tracks);
  __Pyx_GIVEREF(__pyx_v_split_tracks);
  __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 = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.intervals);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.intervals);
  __pyx_v_self->__pyx_base.intervals = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2819
 *         '''load segments from filenames and pre-process them.'''
 *         self.intervals = readFromBed( filenames, split_tracks )
 *         self.normalize()             # <<<<<<<<<<<<<<
 * 
 *     def save( self, outfile, prefix = "", **kwargs ):
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__normalize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_10save(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_9save[] = "IntervalCollection.save(self, outfile, prefix='', **kwargs)\nsave in bed format to *outfile*.\n        \n        Each interval set will be saved as a different track with optional\n        prefix *prefix*.\n\n        Additional *kwargs* will be added to the tracks line as key=value pairs.\n        ";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_10save(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_outfile = 0;
  PyObject *__pyx_v_prefix = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__outfile,&__pyx_n_s__prefix,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_kp_s_80);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__outfile)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "save") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_outfile = values[0];
    __pyx_v_prefix = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("save", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_9save(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_outfile, __pyx_v_prefix, __pyx_v_kwargs);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2821
 *         self.normalize()
 * 
 *     def save( self, outfile, prefix = "", **kwargs ):             # <<<<<<<<<<<<<<
 *         '''save in bed format to *outfile*.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_9save(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_outfile, PyObject *__pyx_v_prefix, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_v_start = NULL;
  PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *(*__pyx_t_16)(PyObject *);
  PyObject *(*__pyx_t_17)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("save", 0);

  /* "GatEngine.pyx":2830
 *         '''
 * 
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             outfile.write("track name=%s%s %s\n" % \
 *                               (prefix, track,
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2831
 * 
 *         for track, vv in self.intervals.iteritems():
 *             outfile.write("track name=%s%s %s\n" % \             # <<<<<<<<<<<<<<
 *                               (prefix, track,
 *                                " ".join( ["%s=%s" % (x,y) for x,y in kwargs.iteritems() ] ) ) )
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "GatEngine.pyx":2833
 *             outfile.write("track name=%s%s %s\n" % \
 *                               (prefix, track,
 *                                " ".join( ["%s=%s" % (x,y) for x,y in kwargs.iteritems() ] ) ) )             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.items():
 *                 for start, end in segmentlist:
 */
    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_82), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = 0;
    __pyx_t_12 = __Pyx_dict_iterator(((PyObject *)__pyx_v_kwargs), 1, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_11), (&__pyx_t_7)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_XDECREF(__pyx_t_9);
    __pyx_t_9 = __pyx_t_12;
    __pyx_t_12 = 0;
    while (1) {
      __pyx_t_14 = __Pyx_dict_iter_next(__pyx_t_9, __pyx_t_11, &__pyx_t_10, &__pyx_t_12, &__pyx_t_13, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_14 == 0)) break;
      if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_12;
      __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_13;
      __pyx_t_13 = 0;
      __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_83), ((PyObject *)__pyx_t_13)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_12));
      __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
      if (unlikely(__Pyx_PyList_Append(__pyx_t_8, (PyObject*)__pyx_t_12))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(((PyObject *)__pyx_t_8));
    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_prefix);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_prefix);
    __Pyx_GIVEREF(__pyx_v_prefix);
    __Pyx_INCREF(__pyx_v_track);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_track);
    __Pyx_GIVEREF(__pyx_v_track);
    PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_81), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
    __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "GatEngine.pyx":2834
 *                               (prefix, track,
 *                                " ".join( ["%s=%s" % (x,y) for x,y in kwargs.iteritems() ] ) ) )
 *             for contig, segmentlist in vv.items():             # <<<<<<<<<<<<<<
 *                 for start, end in segmentlist:
 *                     outfile.write( "%s\t%i\t%i\n" % (contig, start, end))
 */
    __pyx_t_8 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__items); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_9) || PyTuple_CheckExact(__pyx_t_9)) {
      __pyx_t_8 = __pyx_t_9; __Pyx_INCREF(__pyx_t_8); __pyx_t_11 = 0;
      __pyx_t_15 = NULL;
    } else {
      __pyx_t_11 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_15 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    for (;;) {
      if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_9); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_9); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_9 = __pyx_t_15(__pyx_t_8);
        if (unlikely(!__pyx_t_9)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
        PyObject* sequence = __pyx_t_9;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_12 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_16 = Py_TYPE(__pyx_t_12)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_16(__pyx_t_12); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_5 = __pyx_t_16(__pyx_t_12); if (unlikely(!__pyx_t_5)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_16 = NULL;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_16 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L10_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "GatEngine.pyx":2835
 *                                " ".join( ["%s=%s" % (x,y) for x,y in kwargs.iteritems() ] ) ) )
 *             for contig, segmentlist in vv.items():
 *                 for start, end in segmentlist:             # <<<<<<<<<<<<<<
 *                     outfile.write( "%s\t%i\t%i\n" % (contig, start, end))
 * 
 */
      if (PyList_CheckExact(__pyx_v_segmentlist) || PyTuple_CheckExact(__pyx_v_segmentlist)) {
        __pyx_t_9 = __pyx_v_segmentlist; __Pyx_INCREF(__pyx_t_9); __pyx_t_10 = 0;
        __pyx_t_17 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_segmentlist); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_17 = Py_TYPE(__pyx_t_9)->tp_iternext;
      }
      for (;;) {
        if (!__pyx_t_17 && PyList_CheckExact(__pyx_t_9)) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else if (!__pyx_t_17 && PyTuple_CheckExact(__pyx_t_9)) {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          __pyx_t_5 = __pyx_t_17(__pyx_t_9);
          if (unlikely(!__pyx_t_5)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_5);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
          PyObject* sequence = __pyx_t_5;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_12);
          #else
          __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        {
          Py_ssize_t index = -1;
          __pyx_t_13 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_16 = Py_TYPE(__pyx_t_13)->tp_iternext;
          index = 0; __pyx_t_6 = __pyx_t_16(__pyx_t_13); if (unlikely(!__pyx_t_6)) goto __pyx_L13_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_6);
          index = 1; __pyx_t_12 = __pyx_t_16(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_13), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_16 = NULL;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L14_unpacking_done;
          __pyx_L13_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_16 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L14_unpacking_done:;
        }
        __Pyx_XDECREF(__pyx_v_start);
        __pyx_v_start = __pyx_t_6;
        __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_v_end);
        __pyx_v_end = __pyx_t_12;
        __pyx_t_12 = 0;

        /* "GatEngine.pyx":2836
 *             for contig, segmentlist in vv.items():
 *                 for start, end in segmentlist:
 *                     outfile.write( "%s\t%i\t%i\n" % (contig, start, end))             # <<<<<<<<<<<<<<
 * 
 *     def normalize( self ):
 */
        __pyx_t_5 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_v_contig);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_contig);
        __Pyx_GIVEREF(__pyx_v_contig);
        __Pyx_INCREF(__pyx_v_start);
        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_start);
        __Pyx_GIVEREF(__pyx_v_start);
        __Pyx_INCREF(__pyx_v_end);
        PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_end);
        __Pyx_GIVEREF(__pyx_v_end);
        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_84), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
        __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_6));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_12normalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_11normalize[] = "IntervalCollection.normalize(self)\nnormalize segment lists individually.\n\n        Remove empty contigs.\n        ";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_12normalize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("normalize (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_11normalize(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2838
 *                     outfile.write( "%s\t%i\t%i\n" % (contig, start, end))
 * 
 *     def normalize( self ):             # <<<<<<<<<<<<<<
 *         '''normalize segment lists individually.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_11normalize(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("normalize", 0);

  /* "GatEngine.pyx":2844
 *         '''
 * 
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig in vv.keys():
 *                 segmentlist = vv[contig]
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2845
 * 
 *         for track, vv in self.intervals.iteritems():
 *             for contig in vv.keys():             # <<<<<<<<<<<<<<
 *                 segmentlist = vv[contig]
 *                 if len(segmentlist) == 0:
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__keys); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_5 = __pyx_t_9(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "GatEngine.pyx":2846
 *         for track, vv in self.intervals.iteritems():
 *             for contig in vv.keys():
 *                 segmentlist = vv[contig]             # <<<<<<<<<<<<<<
 *                 if len(segmentlist) == 0:
 *                     del vv[contig]
 */
      __pyx_t_5 = PyObject_GetItem(__pyx_v_vv, __pyx_v_contig); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "GatEngine.pyx":2847
 *             for contig in vv.keys():
 *                 segmentlist = vv[contig]
 *                 if len(segmentlist) == 0:             # <<<<<<<<<<<<<<
 *                     del vv[contig]
 *                 else:
 */
      __pyx_t_10 = PyObject_Length(__pyx_v_segmentlist); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = (__pyx_t_10 == 0);
      if (__pyx_t_11) {

        /* "GatEngine.pyx":2848
 *                 segmentlist = vv[contig]
 *                 if len(segmentlist) == 0:
 *                     del vv[contig]             # <<<<<<<<<<<<<<
 *                 else:
 *                     segmentlist.normalize()
 */
        if (unlikely(!__pyx_v_vv)) { __Pyx_RaiseUnboundLocalError("vv"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        if (PyObject_DelItem(__pyx_v_vv, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      /*else*/ {

        /* "GatEngine.pyx":2850
 *                     del vv[contig]
 *                 else:
 *                     segmentlist.normalize()             # <<<<<<<<<<<<<<
 * 
 *     def outputStats( self, outfile ):
 */
        __pyx_t_5 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__normalize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_12 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.normalize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_14outputStats(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_13outputStats[] = "IntervalCollection.outputStats(self, outfile)\noutput segment statistics.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_14outputStats(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("outputStats (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_13outputStats(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_outfile));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2852
 *                     segmentlist.normalize()
 * 
 *     def outputStats( self, outfile ):             # <<<<<<<<<<<<<<
 *         '''output segment statistics.'''
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_13outputStats(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_outfile) {
  __pyx_t_14GatSegmentList_Position __pyx_v_total_length;
  __pyx_t_14GatSegmentList_Position __pyx_v_total_segments;
  __pyx_t_14GatSegmentList_Position __pyx_v_length;
  __pyx_t_14GatSegmentList_Position __pyx_v_segments;
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  __pyx_t_14GatSegmentList_Position __pyx_t_8;
  __pyx_t_14GatSegmentList_Position __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("outputStats", 0);

  /* "GatEngine.pyx":2855
 *         '''output segment statistics.'''
 * 
 *         outfile.write( "section\ttrack\tcontig\tnsegments\tlength\n" )             # <<<<<<<<<<<<<<
 * 
 *         cdef Position total_length = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_86), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2857
 *         outfile.write( "section\ttrack\tcontig\tnsegments\tlength\n" )
 * 
 *         cdef Position total_length = 0             # <<<<<<<<<<<<<<
 *         cdef Position total_segments = 0
 *         cdef Position length, segments
 */
  __pyx_v_total_length = 0;

  /* "GatEngine.pyx":2858
 * 
 *         cdef Position total_length = 0
 *         cdef Position total_segments = 0             # <<<<<<<<<<<<<<
 *         cdef Position length, segments
 *         for track, vv in self.intervals.iteritems():
 */
  __pyx_v_total_segments = 0;

  /* "GatEngine.pyx":2860
 *         cdef Position total_segments = 0
 *         cdef Position length, segments
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             total_length, total_segments = 0, 0
 *             for contig, segmentlist in vv.iteritems():
 */
  __pyx_t_3 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_1;
  __pyx_t_1 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_3, &__pyx_t_1, &__pyx_t_6, NULL, __pyx_t_5);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2861
 *         cdef Position length, segments
 *         for track, vv in self.intervals.iteritems():
 *             total_length, total_segments = 0, 0             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.iteritems():
 *                 segments = len(segmentlist)
 */
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_v_total_length = __pyx_t_8;
    __pyx_v_total_segments = __pyx_t_9;

    /* "GatEngine.pyx":2862
 *         for track, vv in self.intervals.iteritems():
 *             total_length, total_segments = 0, 0
 *             for contig, segmentlist in vv.iteritems():             # <<<<<<<<<<<<<<
 *                 segments = len(segmentlist)
 *                 length = segmentlist.sum()
 */
    __pyx_t_10 = 0;
    if (unlikely(__pyx_v_vv == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_vv, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_11), (&__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_1;
    __pyx_t_1 = 0;
    while (1) {
      __pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_11, &__pyx_t_10, &__pyx_t_1, &__pyx_t_12, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_13 == 0)) break;
      if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "GatEngine.pyx":2863
 *             total_length, total_segments = 0, 0
 *             for contig, segmentlist in vv.iteritems():
 *                 segments = len(segmentlist)             # <<<<<<<<<<<<<<
 *                 length = segmentlist.sum()
 *                 outfile.write( "\t".join( \
 */
      __pyx_t_14 = PyObject_Length(__pyx_v_segmentlist); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_segments = __pyx_t_14;

      /* "GatEngine.pyx":2864
 *             for contig, segmentlist in vv.iteritems():
 *                 segments = len(segmentlist)
 *                 length = segmentlist.sum()             # <<<<<<<<<<<<<<
 *                 outfile.write( "\t".join( \
 *                         (self.name, track, contig,
 */
      __pyx_t_12 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__sum); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_9 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_length = __pyx_t_9;

      /* "GatEngine.pyx":2865
 *                 segments = len(segmentlist)
 *                 length = segmentlist.sum()
 *                 outfile.write( "\t".join( \             # <<<<<<<<<<<<<<
 *                         (self.name, track, contig,
 *                          "%i" % segments,
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);

      /* "GatEngine.pyx":2868
 *                         (self.name, track, contig,
 *                          "%i" % segments,
 *                          "%i" % length ) ) + "\n" )             # <<<<<<<<<<<<<<
 *                 total_length += length
 *                 total_segments += segments
 */
      __pyx_t_12 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_28), __pyx_n_s__join); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);

      /* "GatEngine.pyx":2867
 *                 outfile.write( "\t".join( \
 *                         (self.name, track, contig,
 *                          "%i" % segments,             # <<<<<<<<<<<<<<
 *                          "%i" % length ) ) + "\n" )
 *                 total_length += length
 */
      __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_segments); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_16));
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

      /* "GatEngine.pyx":2868
 *                         (self.name, track, contig,
 *                          "%i" % segments,
 *                          "%i" % length ) ) + "\n" )             # <<<<<<<<<<<<<<
 *                 total_length += length
 *                 total_segments += segments
 */
      __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_length); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_17 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_t_15); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_17));
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
      PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
      __Pyx_INCREF(__pyx_v_track);
      PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_track);
      __Pyx_GIVEREF(__pyx_v_track);
      __Pyx_INCREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_contig);
      __Pyx_GIVEREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_15, 3, ((PyObject *)__pyx_t_16));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_16));
      PyTuple_SET_ITEM(__pyx_t_15, 4, ((PyObject *)__pyx_t_17));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_17));
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_17 = PyTuple_New(1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_17, 0, ((PyObject *)__pyx_t_15));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_15));
      __pyx_t_15 = 0;
      __pyx_t_15 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_t_17), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_17)); __pyx_t_17 = 0;
      __pyx_t_17 = PyNumber_Add(__pyx_t_15, ((PyObject *)__pyx_kp_s_87)); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_17);
      __pyx_t_17 = 0;
      __pyx_t_17 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "GatEngine.pyx":2869
 *                          "%i" % segments,
 *                          "%i" % length ) ) + "\n" )
 *                 total_length += length             # <<<<<<<<<<<<<<
 *                 total_segments += segments
 *             outfile.write("\t".join( \
 */
      __pyx_v_total_length = (__pyx_v_total_length + __pyx_v_length);

      /* "GatEngine.pyx":2870
 *                          "%i" % length ) ) + "\n" )
 *                 total_length += length
 *                 total_segments += segments             # <<<<<<<<<<<<<<
 *             outfile.write("\t".join( \
 *                 (self.name, track, "total",
 */
      __pyx_v_total_segments = (__pyx_v_total_segments + __pyx_v_segments);
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "GatEngine.pyx":2871
 *                 total_length += length
 *                 total_segments += segments
 *             outfile.write("\t".join( \             # <<<<<<<<<<<<<<
 *                 (self.name, track, "total",
 *                          "%i" % total_segments,
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "GatEngine.pyx":2874
 *                 (self.name, track, "total",
 *                          "%i" % total_segments,
 *                          "%i" % total_length ) ) + "\n" )             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_17 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_28), __pyx_n_s__join); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);

    /* "GatEngine.pyx":2873
 *             outfile.write("\t".join( \
 *                 (self.name, track, "total",
 *                          "%i" % total_segments,             # <<<<<<<<<<<<<<
 *                          "%i" % total_length ) ) + "\n" )
 * 
 */
    __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_total_segments); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_t_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

    /* "GatEngine.pyx":2874
 *                 (self.name, track, "total",
 *                          "%i" % total_segments,
 *                          "%i" % total_length ) ) + "\n" )             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_total_length); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_t_15); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_12));
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
    PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
    __Pyx_INCREF(__pyx_v_track);
    PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_track);
    __Pyx_GIVEREF(__pyx_v_track);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__total));
    PyTuple_SET_ITEM(__pyx_t_15, 2, ((PyObject *)__pyx_n_s__total));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__total));
    PyTuple_SET_ITEM(__pyx_t_15, 3, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    PyTuple_SET_ITEM(__pyx_t_15, 4, ((PyObject *)__pyx_t_12));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
    __pyx_t_1 = 0;
    __pyx_t_12 = 0;
    __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_15));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_15));
    __pyx_t_15 = 0;
    __pyx_t_15 = PyObject_Call(__pyx_t_17, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
    __pyx_t_12 = PyNumber_Add(__pyx_t_15, ((PyObject *)__pyx_kp_s_87)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.outputStats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_16merge(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_15merge[] = "IntervalCollection.merge(self, delete=False)\nmerge all tracks into a single segment list\n        creating a new track called 'merged'.\n\n        Overlapping intervals will be merged.\n\n        If *delete* == True, all tracks but the merged track\n        will be deleted.\n        ";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_16merge(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_delete = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("merge (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__delete,0};
    PyObject* values[1] = {0};
    values[0] = __pyx_k_88;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__delete);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "merge") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2877; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_delete = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("merge", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2877; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.merge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_15merge(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_delete);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2877
 * 
 * 
 *     def merge( self, delete = False ):             # <<<<<<<<<<<<<<
 *         '''merge all tracks into a single segment list
 *         creating a new track called 'merged'.
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_15merge(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_delete) {
  struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_merged = NULL;
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("merge", 0);

  /* "GatEngine.pyx":2886
 *         will be deleted.
 *         '''
 *         merged = IntervalDictionary()             # <<<<<<<<<<<<<<
 * 
 *         for track in self.intervals.keys():
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_merged = ((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":2888
 *         merged = IntervalDictionary()
 * 
 *         for track in self.intervals.keys():             # <<<<<<<<<<<<<<
 *             vv = self.intervals[track]
 *             for contig, segmentlist in vv.iteritems():
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2889
 * 
 *         for track in self.intervals.keys():
 *             vv = self.intervals[track]             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.iteritems():
 *                 merged[contig].extend( segmentlist )
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_track); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2890
 *         for track in self.intervals.keys():
 *             vv = self.intervals[track]
 *             for contig, segmentlist in vv.iteritems():             # <<<<<<<<<<<<<<
 *                 merged[contig].extend( segmentlist )
 *             if delete:
 */
    __pyx_t_5 = 0;
    if (unlikely(__pyx_v_vv == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = __Pyx_dict_iterator(__pyx_v_vv, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_XDECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_8;
    __pyx_t_8 = 0;
    while (1) {
      __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_6, &__pyx_t_5, &__pyx_t_8, &__pyx_t_9, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_10 == 0)) break;
      if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "GatEngine.pyx":2891
 *             vv = self.intervals[track]
 *             for contig, segmentlist in vv.iteritems():
 *                 merged[contig].extend( segmentlist )             # <<<<<<<<<<<<<<
 *             if delete:
 *                 del self.intervals[track]
 */
      __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_merged), __pyx_v_contig); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__extend); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_segmentlist);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_segmentlist);
      __Pyx_GIVEREF(__pyx_v_segmentlist);
      __pyx_t_11 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "GatEngine.pyx":2892
 *             for contig, segmentlist in vv.iteritems():
 *                 merged[contig].extend( segmentlist )
 *             if delete:             # <<<<<<<<<<<<<<
 *                 del self.intervals[track]
 * 
 */
    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_delete); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_12) {

      /* "GatEngine.pyx":2893
 *                 merged[contig].extend( segmentlist )
 *             if delete:
 *                 del self.intervals[track]             # <<<<<<<<<<<<<<
 * 
 *         self.intervals["merged"] = merged
 */
      if (unlikely(!__pyx_v_track)) { __Pyx_RaiseUnboundLocalError("track"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2895
 *                 del self.intervals[track]
 * 
 *         self.intervals["merged"] = merged             # <<<<<<<<<<<<<<
 *         self.normalize()
 * 
 */
  if (PyObject_SetItem(__pyx_v_self->__pyx_base.intervals, ((PyObject *)__pyx_n_s__merged), ((PyObject *)__pyx_v_merged)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2896
 * 
 *         self.intervals["merged"] = merged
 *         self.normalize()             # <<<<<<<<<<<<<<
 * 
 *     def collapse( self ):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__normalize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.merge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_merged);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_18collapse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_17collapse[] = "IntervalCollection.collapse(self)\ncollapse all tracks into a single segment list\n        creating a new track called 'collapsed'.\n\n        The collapsed track contains the intersection of\n        all segment lists.\n        ";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_18collapse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("collapse (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_17collapse(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2898
 *         self.normalize()
 * 
 *     def collapse( self ):             # <<<<<<<<<<<<<<
 *         '''collapse all tracks into a single segment list
 *         creating a new track called 'collapsed'.
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_17collapse(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  struct __pyx_obj_9GatEngine_IntervalDictionary *__pyx_v_result = NULL;
  PyObject *__pyx_v_contigs = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_ntracks = NULL;
  PyObject *__pyx_v_shared_contigs = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("collapse", 0);

  /* "GatEngine.pyx":2905
 *         all segment lists.
 *         '''
 *         result = IntervalDictionary()             # <<<<<<<<<<<<<<
 * 
 *         # get list of contigs present in all data sets
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalDictionary)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((struct __pyx_obj_9GatEngine_IntervalDictionary *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":2908
 * 
 *         # get list of contigs present in all data sets
 *         contigs = collections.defaultdict( int )             # <<<<<<<<<<<<<<
 *         for track, vv in self.intervals.iteritems():
 *             for contig in vv.keys():
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyInt_Type))));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)(&PyInt_Type))));
  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyInt_Type))));
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_contigs = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2909
 *         # get list of contigs present in all data sets
 *         contigs = collections.defaultdict( int )
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig in vv.keys():
 *                 contigs[contig] += 1
 */
  __pyx_t_4 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_1;
  __pyx_t_1 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_5, &__pyx_t_4, &__pyx_t_1, &__pyx_t_2, NULL, __pyx_t_6);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":2910
 *         contigs = collections.defaultdict( int )
 *         for track, vv in self.intervals.iteritems():
 *             for contig in vv.keys():             # <<<<<<<<<<<<<<
 *                 contigs[contig] += 1
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "GatEngine.pyx":2911
 *         for track, vv in self.intervals.iteritems():
 *             for contig in vv.keys():
 *                 contigs[contig] += 1             # <<<<<<<<<<<<<<
 * 
 *         ntracks = len( self.intervals )
 */
      __Pyx_INCREF(__pyx_v_contig);
      __pyx_t_1 = __pyx_v_contig;
      __pyx_t_10 = PyObject_GetItem(__pyx_v_contigs, __pyx_t_1); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_t_10, __pyx_int_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (PyObject_SetItem(__pyx_v_contigs, __pyx_t_1, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2913
 *                 contigs[contig] += 1
 * 
 *         ntracks = len( self.intervals )             # <<<<<<<<<<<<<<
 *         shared_contigs = set( [ x for x,y in contigs.iteritems() if y == ntracks ] )
 * 
 */
  __pyx_t_3 = __pyx_v_self->__pyx_base.intervals;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ntracks = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2914
 * 
 *         ntracks = len( self.intervals )
 *         shared_contigs = set( [ x for x,y in contigs.iteritems() if y == ntracks ] )             # <<<<<<<<<<<<<<
 * 
 *         for track, vv in self.intervals.iteritems():
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 0;
  if (unlikely(__pyx_v_contigs == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_contigs, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_4), (&__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_1;
  __pyx_t_1 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_5, &__pyx_t_1, &__pyx_t_11, NULL, __pyx_t_6);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_y);
    __pyx_v_y = __pyx_t_11;
    __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_RichCompare(__pyx_v_y, __pyx_v_ntracks, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (__pyx_t_12) {
      if (unlikely(__Pyx_PyList_Append(__pyx_t_3, (PyObject*)__pyx_v_x))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_shared_contigs = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":2916
 *         shared_contigs = set( [ x for x,y in contigs.iteritems() if y == ntracks ] )
 * 
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.iteritems():
 *                 if contig not in shared_contigs: continue
 */
  __pyx_t_4 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_2;
  __pyx_t_2 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_5, &__pyx_t_4, &__pyx_t_2, &__pyx_t_11, NULL, __pyx_t_6);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_11;
    __pyx_t_11 = 0;

    /* "GatEngine.pyx":2917
 * 
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.iteritems():             # <<<<<<<<<<<<<<
 *                 if contig not in shared_contigs: continue
 *                 if contig not in result:
 */
    __pyx_t_8 = 0;
    if (unlikely(__pyx_v_vv == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_vv, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_13), (&__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_11);
    __pyx_t_11 = __pyx_t_2;
    __pyx_t_2 = 0;
    while (1) {
      __pyx_t_14 = __Pyx_dict_iter_next(__pyx_t_11, __pyx_t_13, &__pyx_t_8, &__pyx_t_2, &__pyx_t_1, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_14 == 0)) break;
      if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "GatEngine.pyx":2918
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.iteritems():
 *                 if contig not in shared_contigs: continue             # <<<<<<<<<<<<<<
 *                 if contig not in result:
 *                     result[contig] = SegmentList( clone = segmentlist )
 */
      __pyx_t_12 = (__Pyx_PySequence_Contains(__pyx_v_contig, ((PyObject *)__pyx_v_shared_contigs), Py_NE)); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_12) {
        goto __pyx_L12_continue;
        goto __pyx_L14;
      }
      __pyx_L14:;

      /* "GatEngine.pyx":2919
 *             for contig, segmentlist in vv.iteritems():
 *                 if contig not in shared_contigs: continue
 *                 if contig not in result:             # <<<<<<<<<<<<<<
 *                     result[contig] = SegmentList( clone = segmentlist )
 *                 else:
 */
      __pyx_t_12 = (__Pyx_PySequence_Contains(__pyx_v_contig, ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_12) {

        /* "GatEngine.pyx":2920
 *                 if contig not in shared_contigs: continue
 *                 if contig not in result:
 *                     result[contig] = SegmentList( clone = segmentlist )             # <<<<<<<<<<<<<<
 *                 else:
 *                     result[contig].intersect( segmentlist )
 */
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        if (PyObject_SetItem(((PyObject *)__pyx_v_result), __pyx_v_contig, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L15;
      }
      /*else*/ {

        /* "GatEngine.pyx":2922
 *                     result[contig] = SegmentList( clone = segmentlist )
 *                 else:
 *                     result[contig].intersect( segmentlist )             # <<<<<<<<<<<<<<
 * 
 *         self.intervals["collapsed"] = result
 */
        __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_result), __pyx_v_contig); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__intersect); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_segmentlist);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_segmentlist);
        __Pyx_GIVEREF(__pyx_v_segmentlist);
        __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __pyx_L15:;
      __pyx_L12_continue:;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":2924
 *                     result[contig].intersect( segmentlist )
 * 
 *         self.intervals["collapsed"] = result             # <<<<<<<<<<<<<<
 * 
 *     def countsPerTrack( self ):
 */
  if (PyObject_SetItem(__pyx_v_self->__pyx_base.intervals, ((PyObject *)__pyx_n_s__collapsed), ((PyObject *)__pyx_v_result)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.collapse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_contigs);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_ntracks);
  __Pyx_XDECREF(__pyx_v_shared_contigs);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_20countsPerTrack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_19countsPerTrack[] = "IntervalCollection.countsPerTrack(self)\nreturn number of all segments in all segments lists.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_20countsPerTrack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("countsPerTrack (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_19countsPerTrack(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2926
 *         self.intervals["collapsed"] = result
 * 
 *     def countsPerTrack( self ):             # <<<<<<<<<<<<<<
 *         '''return number of all segments in all segments lists.'''
 *         counts = {}
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_19countsPerTrack(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  PyObject *__pyx_v_counts = NULL;
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_s = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("countsPerTrack", 0);

  /* "GatEngine.pyx":2928
 *     def countsPerTrack( self ):
 *         '''return number of all segments in all segments lists.'''
 *         counts = {}             # <<<<<<<<<<<<<<
 *         for track, vv in self.intervals.iteritems():
 *             s = 0
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_counts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":2929
 *         '''return number of all segments in all segments lists.'''
 *         counts = {}
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             s = 0
 *             for contig, segmentlist in vv.iteritems():
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2930
 *         counts = {}
 *         for track, vv in self.intervals.iteritems():
 *             s = 0             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.iteritems():
 *                 s += len(segmentlist)
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_XDECREF(__pyx_v_s);
    __pyx_v_s = __pyx_int_0;

    /* "GatEngine.pyx":2931
 *         for track, vv in self.intervals.iteritems():
 *             s = 0
 *             for contig, segmentlist in vv.iteritems():             # <<<<<<<<<<<<<<
 *                 s += len(segmentlist)
 *             counts[track] = s
 */
    __pyx_t_8 = 0;
    if (unlikely(__pyx_v_vv == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_vv, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_9), (&__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_5;
    __pyx_t_5 = 0;
    while (1) {
      __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_8, &__pyx_t_5, &__pyx_t_10, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_11 == 0)) break;
      if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "GatEngine.pyx":2932
 *             s = 0
 *             for contig, segmentlist in vv.iteritems():
 *                 s += len(segmentlist)             # <<<<<<<<<<<<<<
 *             counts[track] = s
 *         return counts
 */
      __pyx_t_12 = PyObject_Length(__pyx_v_segmentlist); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_t_5;
      __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "GatEngine.pyx":2933
 *             for contig, segmentlist in vv.iteritems():
 *                 s += len(segmentlist)
 *             counts[track] = s             # <<<<<<<<<<<<<<
 *         return counts
 * 
 */
    if (PyDict_SetItem(((PyObject *)__pyx_v_counts), __pyx_v_track, __pyx_v_s) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2934
 *                 s += len(segmentlist)
 *             counts[track] = s
 *         return counts             # <<<<<<<<<<<<<<
 * 
 *     def intersect( self, other ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_counts));
  __pyx_r = ((PyObject *)__pyx_v_counts);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.countsPerTrack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_22intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_21intersect[] = "IntervalCollection.intersect(self, other)\nintersect with intervals in other.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_22intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("intersect (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_21intersect(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_other));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2936
 *         return counts
 * 
 *     def intersect( self, other ):             # <<<<<<<<<<<<<<
 *         '''intersect with intervals in other.'''
 *         for track, vv in self.intervals.iteritems():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_21intersect(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("intersect", 0);

  /* "GatEngine.pyx":2938
 *     def intersect( self, other ):
 *         '''intersect with intervals in other.'''
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.items():
 *                 if contig in other:
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2939
 *         '''intersect with intervals in other.'''
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.items():             # <<<<<<<<<<<<<<
 *                 if contig in other:
 *                     segmentlist.intersect( other[contig] )
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__items); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_5 = __pyx_t_9(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        #else
        __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
        index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_11;
      __pyx_t_11 = 0;

      /* "GatEngine.pyx":2940
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.items():
 *                 if contig in other:             # <<<<<<<<<<<<<<
 *                     segmentlist.intersect( other[contig] )
 *                 else:
 */
      __pyx_t_14 = (__Pyx_PySequence_Contains(__pyx_v_contig, __pyx_v_other, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_14) {

        /* "GatEngine.pyx":2941
 *             for contig, segmentlist in vv.items():
 *                 if contig in other:
 *                     segmentlist.intersect( other[contig] )             # <<<<<<<<<<<<<<
 *                 else:
 *                     del vv[contig]
 */
        __pyx_t_5 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__intersect); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_11 = PyObject_GetItem(__pyx_v_other, __pyx_v_contig); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "GatEngine.pyx":2943
 *                     segmentlist.intersect( other[contig] )
 *                 else:
 *                     del vv[contig]             # <<<<<<<<<<<<<<
 * 
 *     def filter( self, other ):
 */
        if (unlikely(!__pyx_v_vv)) { __Pyx_RaiseUnboundLocalError("vv"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        if (PyObject_DelItem(__pyx_v_vv, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L9:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_24filter(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_23filter[] = "IntervalCollection.filter(self, other)\nremove all intervals not overlapping with intervals in other.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_24filter(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("filter (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_23filter(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_other));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2945
 *                     del vv[contig]
 * 
 *     def filter( self, other ):             # <<<<<<<<<<<<<<
 *         '''remove all intervals not overlapping with intervals in other.'''
 *         for track, vv in self.intervals.iteritems():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_23filter(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("filter", 0);

  /* "GatEngine.pyx":2947
 *     def filter( self, other ):
 *         '''remove all intervals not overlapping with intervals in other.'''
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.items():
 *                 if contig in other:
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2948
 *         '''remove all intervals not overlapping with intervals in other.'''
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.items():             # <<<<<<<<<<<<<<
 *                 if contig in other:
 *                     segmentlist.filter( other[contig] )
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__items); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
      __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    for (;;) {
      if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_5 = __pyx_t_9(__pyx_t_6);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
        PyObject* sequence = __pyx_t_5;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        #else
        __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
        index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_11;
      __pyx_t_11 = 0;

      /* "GatEngine.pyx":2949
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.items():
 *                 if contig in other:             # <<<<<<<<<<<<<<
 *                     segmentlist.filter( other[contig] )
 *                 else:
 */
      __pyx_t_14 = (__Pyx_PySequence_Contains(__pyx_v_contig, __pyx_v_other, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_14) {

        /* "GatEngine.pyx":2950
 *             for contig, segmentlist in vv.items():
 *                 if contig in other:
 *                     segmentlist.filter( other[contig] )             # <<<<<<<<<<<<<<
 *                 else:
 *                     del vv[contig]
 */
        __pyx_t_5 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__filter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_11 = PyObject_GetItem(__pyx_v_other, __pyx_v_contig); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "GatEngine.pyx":2952
 *                     segmentlist.filter( other[contig] )
 *                 else:
 *                     del vv[contig]             # <<<<<<<<<<<<<<
 * 
 *     def restrict( self, restrict ):
 */
        if (unlikely(!__pyx_v_vv)) { __Pyx_RaiseUnboundLocalError("vv"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        if (unlikely(!__pyx_v_contig)) { __Pyx_RaiseUnboundLocalError("contig"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        if (PyObject_DelItem(__pyx_v_vv, __pyx_v_contig) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L9:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_26restrict(PyObject *__pyx_v_self, PyObject *__pyx_v_restrict); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_25restrict[] = "IntervalCollection.restrict(self, restrict)\nremove all tracks except those in restrict.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_26restrict(PyObject *__pyx_v_self, PyObject *__pyx_v_restrict) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("restrict (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_25restrict(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_restrict));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2954
 *                     del vv[contig]
 * 
 *     def restrict( self, restrict ):             # <<<<<<<<<<<<<<
 *         '''remove all tracks except those in restrict.'''
 *         if restrict in (list, tuple, set):
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_25restrict(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_restrict) {
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("restrict", 0);

  /* "GatEngine.pyx":2956
 *     def restrict( self, restrict ):
 *         '''remove all tracks except those in restrict.'''
 *         if restrict in (list, tuple, set):             # <<<<<<<<<<<<<<
 *             r = set(restrict)
 *         else:
 */
  __Pyx_INCREF(__pyx_v_restrict);
  __pyx_t_1 = __pyx_v_restrict;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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 = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!((int)__pyx_t_3)) {
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)((PyObject*)(&PyTuple_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = ((int)__pyx_t_4);
  } else {
    __pyx_t_5 = ((int)__pyx_t_3);
  }
  if (!__pyx_t_5) {
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)((PyObject*)(&PySet_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __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 = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((int)__pyx_t_3);
  } else {
    __pyx_t_4 = __pyx_t_5;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __pyx_t_4;
  if (__pyx_t_5) {

    /* "GatEngine.pyx":2957
 *         '''remove all tracks except those in restrict.'''
 *         if restrict in (list, tuple, set):
 *             r = set(restrict)             # <<<<<<<<<<<<<<
 *         else:
 *             r = set( [restrict,] )
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_restrict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_restrict);
    __Pyx_GIVEREF(__pyx_v_restrict);
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_v_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":2959
 *             r = set(restrict)
 *         else:
 *             r = set( [restrict,] )             # <<<<<<<<<<<<<<
 * 
 *         for track in self.intervals.keys():
 */
    __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    if (unlikely(PySet_Add(__pyx_t_2, __pyx_v_restrict) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_r = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":2961
 *             r = set( [restrict,] )
 * 
 *         for track in self.intervals.keys():             # <<<<<<<<<<<<<<
 *             if track not in r:
 *                 del self.intervals[track]
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "GatEngine.pyx":2962
 * 
 *         for track in self.intervals.keys():
 *             if track not in r:             # <<<<<<<<<<<<<<
 *                 del self.intervals[track]
 * 
 */
    __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_v_track, ((PyObject *)__pyx_v_r), Py_NE)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_5) {

      /* "GatEngine.pyx":2963
 *         for track in self.intervals.keys():
 *             if track not in r:
 *                 del self.intervals[track]             # <<<<<<<<<<<<<<
 * 
 *     def toIsochores( self, isochores, truncate = False ):
 */
      if (unlikely(!__pyx_v_track)) { __Pyx_RaiseUnboundLocalError("track"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.restrict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_28toIsochores(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_27toIsochores[] = "IntervalCollection.toIsochores(self, isochores, truncate=False)\nsplit per-contig segmentlists into per-isochore segmentlist.\n\n        If *truncate* is given, the segments are truncated at isochore\n        boundaries.\n\n        The IntervalCollection is modified in-place.\n        ";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_28toIsochores(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_isochores = 0;
  PyObject *__pyx_v_truncate = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("toIsochores (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__isochores,&__pyx_n_s__truncate,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k_89;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochores)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__truncate);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "toIsochores") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_isochores = values[0];
    __pyx_v_truncate = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("toIsochores", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.toIsochores", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_27toIsochores(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_isochores, __pyx_v_truncate);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2965
 *                 del self.intervals[track]
 * 
 *     def toIsochores( self, isochores, truncate = False ):             # <<<<<<<<<<<<<<
 *         '''split per-contig segmentlists into per-isochore segmentlist.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_27toIsochores(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_isochores, PyObject *__pyx_v_truncate) {
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("toIsochores", 0);

  /* "GatEngine.pyx":2973
 *         The IntervalCollection is modified in-place.
 *         '''
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             vv.toIsochores( isochores, truncate )
 * 
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2974
 *         '''
 *         for track, vv in self.intervals.iteritems():
 *             vv.toIsochores( isochores, truncate )             # <<<<<<<<<<<<<<
 * 
 *     def fromIsochores( self ):
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__toIsochores); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_isochores);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_isochores);
    __Pyx_GIVEREF(__pyx_v_isochores);
    __Pyx_INCREF(__pyx_v_truncate);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_truncate);
    __Pyx_GIVEREF(__pyx_v_truncate);
    __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.toIsochores", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_30fromIsochores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_29fromIsochores[] = "IntervalCollection.fromIsochores(self)\nmerge isochores together.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_30fromIsochores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fromIsochores (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_29fromIsochores(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2976
 *             vv.toIsochores( isochores, truncate )
 * 
 *     def fromIsochores( self ):             # <<<<<<<<<<<<<<
 *         '''merge isochores together.'''
 *         for track, vv in self.intervals.iteritems():
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_29fromIsochores(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  CYTHON_UNUSED PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fromIsochores", 0);

  /* "GatEngine.pyx":2978
 *     def fromIsochores( self ):
 *         '''merge isochores together.'''
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             vv.fromIsochores( )
 * 
 */
  __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2979
 *         '''merge isochores together.'''
 *         for track, vv in self.intervals.iteritems():
 *             vv.fromIsochores( )             # <<<<<<<<<<<<<<
 * 
 *     def clone( self ):
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_vv, __pyx_n_s__fromIsochores); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.fromIsochores", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_32clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_31clone[] = "IntervalCollection.clone(self)\nreturn a copy of self.";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_32clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clone (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_31clone(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2981
 *             vv.fromIsochores( )
 * 
 *     def clone( self ):             # <<<<<<<<<<<<<<
 *         '''return a copy of self.'''
 *         new = IntervalCollection( self.name )
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_31clone(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_new = NULL;
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clone", 0);

  /* "GatEngine.pyx":2983
 *     def clone( self ):
 *         '''return a copy of self.'''
 *         new = IntervalCollection( self.name )             # <<<<<<<<<<<<<<
 *         for track,v in self.intervals.iteritems():
 *             for contig, segmentlist in v.iteritems():
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalCollection)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_new = ((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":2984
 *         '''return a copy of self.'''
 *         new = IntervalCollection( self.name )
 *         for track,v in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in v.iteritems():
 *                 new.add( track, contig, SegmentList( clone = segmentlist) )
 */
  __pyx_t_3 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_1;
  __pyx_t_1 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_3, &__pyx_t_1, &__pyx_t_6, NULL, __pyx_t_5);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_v);
    __pyx_v_v = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":2985
 *         new = IntervalCollection( self.name )
 *         for track,v in self.intervals.iteritems():
 *             for contig, segmentlist in v.iteritems():             # <<<<<<<<<<<<<<
 *                 new.add( track, contig, SegmentList( clone = segmentlist) )
 *         return new
 */
    __pyx_t_8 = 0;
    if (unlikely(__pyx_v_v == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_v, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_9), (&__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_1;
    __pyx_t_1 = 0;
    while (1) {
      __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_8, &__pyx_t_1, &__pyx_t_10, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_11 == 0)) break;
      if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "GatEngine.pyx":2986
 *         for track,v in self.intervals.iteritems():
 *             for contig, segmentlist in v.iteritems():
 *                 new.add( track, contig, SegmentList( clone = segmentlist) )             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
      __pyx_t_10 = PyObject_GetAttr(((PyObject *)__pyx_v_new), __pyx_n_s__add); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__clone), __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_track);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_track);
      __Pyx_GIVEREF(__pyx_v_track);
      __Pyx_INCREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_contig);
      __Pyx_GIVEREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2987
 *             for contig, segmentlist in v.iteritems():
 *                 new.add( track, contig, SegmentList( clone = segmentlist) )
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_34tracks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_33tracks[] = "IntervalCollection.tracks(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_34tracks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tracks (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_33tracks(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2990
 * 
 *     @property
 *     def tracks(self): return self.intervals.keys()             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self): return len(self.intervals)
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_33tracks(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tracks", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.tracks", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static Py_ssize_t __pyx_pw_9GatEngine_18IntervalCollection_36__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_9GatEngine_18IntervalCollection_36__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_35__len__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2992
 *     def tracks(self): return self.intervals.keys()
 * 
 *     def __len__(self): return len(self.intervals)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self,key): del self.intervals[key]
 */

static Py_ssize_t __pyx_pf_9GatEngine_18IntervalCollection_35__len__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);
  __pyx_t_1 = __pyx_v_self->__pyx_base.intervals;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalCollection_38__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalCollection_38__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_37__delitem__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2994
 *     def __len__(self): return len(self.intervals)
 * 
 *     def __delitem__(self,key): del self.intervals[key]             # <<<<<<<<<<<<<<
 * 
 *     def keys(self): return self.intervals.keys()
 */

static int __pyx_pf_9GatEngine_18IntervalCollection_37__delitem__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delitem__", 0);
  if (PyObject_DelItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_40keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_39keys[] = "IntervalCollection.keys(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_40keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_39keys(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2996
 *     def __delitem__(self,key): del self.intervals[key]
 * 
 *     def keys(self): return self.intervals.keys()             # <<<<<<<<<<<<<<
 * 
 *     def add( self, track, contig, segmentlist ):
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_39keys(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_42add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_41add[] = "IntervalCollection.add(self, track, contig, segmentlist)";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_42add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_contig = 0;
  PyObject *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__contig,&__pyx_n_s__segmentlist,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__contig)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2998; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segmentlist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2998; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2998; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_contig = values[1];
    __pyx_v_segmentlist = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2998; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_41add(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_track, __pyx_v_contig, __pyx_v_segmentlist);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":2998
 *     def keys(self): return self.intervals.keys()
 * 
 *     def add( self, track, contig, segmentlist ):             # <<<<<<<<<<<<<<
 *         self.intervals[track][contig] = segmentlist
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_41add(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_contig, PyObject *__pyx_v_segmentlist) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);

  /* "GatEngine.pyx":2999
 * 
 *     def add( self, track, contig, segmentlist ):
 *         self.intervals[track][contig] = segmentlist             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key ):
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_track); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_1, __pyx_v_contig, __pyx_v_segmentlist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_44__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_44__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_43__getitem__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3001
 *         self.intervals[track][contig] = segmentlist
 * 
 *     def __getitem__(self, key ):             # <<<<<<<<<<<<<<
 *         return self.intervals[key]
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_43__getitem__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "GatEngine.pyx":3002
 * 
 *     def __getitem__(self, key ):
 *         return self.intervals[key]             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->__pyx_base.intervals, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_18IntervalCollection_46__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_9GatEngine_18IntervalCollection_46__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_45__contains__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3004
 *         return self.intervals[key]
 * 
 *     def __contains__(self, key ):             # <<<<<<<<<<<<<<
 *         return key in self.intervals
 * 
 */

static int __pyx_pf_9GatEngine_18IntervalCollection_45__contains__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "GatEngine.pyx":3005
 * 
 *     def __contains__(self, key ):
 *         return key in self.intervals             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_v_self->__pyx_base.intervals, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_48__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_48__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_47__str__(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3007
 *         return key in self.intervals
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s:%s" % (self.name,
 *                           ",".join( ["%s:%s" % (x,y) for x,y in self.intervals.iteritems()]))
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_47__str__(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "GatEngine.pyx":3008
 * 
 *     def __str__(self):
 *         return "%s:%s" % (self.name,             # <<<<<<<<<<<<<<
 *                           ",".join( ["%s:%s" % (x,y) for x,y in self.intervals.iteritems()]))
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "GatEngine.pyx":3009
 *     def __str__(self):
 *         return "%s:%s" % (self.name,
 *                           ",".join( ["%s:%s" % (x,y) for x,y in self.intervals.iteritems()]))             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_91), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_7;
  __pyx_t_7 = 0;
  while (1) {
    __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_5, &__pyx_t_4, &__pyx_t_7, &__pyx_t_8, NULL, __pyx_t_6);
    if (unlikely(__pyx_t_9 == 0)) break;
    if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_XDECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_7;
    __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_v_y);
    __pyx_v_y = __pyx_t_8;
    __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_x);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_x);
    __Pyx_GIVEREF(__pyx_v_x);
    __Pyx_INCREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_90), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (unlikely(__Pyx_PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_90), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_50iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_49iteritems[] = "IntervalCollection.iteritems(self)";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_50iteritems(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iteritems (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_49iteritems(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3011
 *                           ",".join( ["%s:%s" % (x,y) for x,y in self.intervals.iteritems()]))
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         return self.intervals.iteritems()
 * 
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_49iteritems(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iteritems", 0);

  /* "GatEngine.pyx":3012
 * 
 *     def iteritems(self):
 *         return self.intervals.iteritems()             # <<<<<<<<<<<<<<
 * 
 *     def outputOverlapStats( self, outfile, other ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base.intervals, __pyx_n_s__iteritems); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.iteritems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_52outputOverlapStats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_18IntervalCollection_51outputOverlapStats[] = "IntervalCollection.outputOverlapStats(self, outfile, other)";
static PyObject *__pyx_pw_9GatEngine_18IntervalCollection_52outputOverlapStats(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_outfile = 0;
  PyObject *__pyx_v_other = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("outputOverlapStats (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__outfile,&__pyx_n_s__other,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__outfile)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__other)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("outputOverlapStats", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3014; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "outputOverlapStats") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3014; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_outfile = values[0];
    __pyx_v_other = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("outputOverlapStats", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3014; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.IntervalCollection.outputOverlapStats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_18IntervalCollection_51outputOverlapStats(((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_v_self), __pyx_v_outfile, __pyx_v_other);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3014
 *         return self.intervals.iteritems()
 * 
 *     def outputOverlapStats( self, outfile, other ):             # <<<<<<<<<<<<<<
 * 
 *         outfile.write( "section\ttrack\tcontig\toverlap\tlength\tdensity\n" )
 */

static PyObject *__pyx_pf_9GatEngine_18IntervalCollection_51outputOverlapStats(struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_self, PyObject *__pyx_v_outfile, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_track = NULL;
  PyObject *__pyx_v_vv = NULL;
  PyObject *__pyx_v_contig = NULL;
  PyObject *__pyx_v_segmentlist = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_v_overlap = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  double __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("outputOverlapStats", 0);

  /* "GatEngine.pyx":3016
 *     def outputOverlapStats( self, outfile, other ):
 * 
 *         outfile.write( "section\ttrack\tcontig\toverlap\tlength\tdensity\n" )             # <<<<<<<<<<<<<<
 * 
 *         for track, vv in self.intervals.iteritems():
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_93), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":3018
 *         outfile.write( "section\ttrack\tcontig\toverlap\tlength\tdensity\n" )
 * 
 *         for track, vv in self.intervals.iteritems():             # <<<<<<<<<<<<<<
 *             for contig, segmentlist in vv.iteritems():
 *                 length = segmentlist.sum()
 */
  __pyx_t_3 = 0;
  if (unlikely(__pyx_v_self->__pyx_base.intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_self->__pyx_base.intervals, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_1;
  __pyx_t_1 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_3, &__pyx_t_1, &__pyx_t_6, NULL, __pyx_t_5);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_vv);
    __pyx_v_vv = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":3019
 * 
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.iteritems():             # <<<<<<<<<<<<<<
 *                 length = segmentlist.sum()
 *                 if length == 0: continue
 */
    __pyx_t_8 = 0;
    if (unlikely(__pyx_v_vv == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_vv, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_9), (&__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_6);
    __pyx_t_6 = __pyx_t_1;
    __pyx_t_1 = 0;
    while (1) {
      __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_8, &__pyx_t_1, &__pyx_t_10, NULL, __pyx_t_7);
      if (unlikely(__pyx_t_11 == 0)) break;
      if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_v_contig);
      __pyx_v_contig = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_v_segmentlist);
      __pyx_v_segmentlist = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "GatEngine.pyx":3020
 *         for track, vv in self.intervals.iteritems():
 *             for contig, segmentlist in vv.iteritems():
 *                 length = segmentlist.sum()             # <<<<<<<<<<<<<<
 *                 if length == 0: continue
 *                 overlap = segmentlist.overlapWithSegments(other[contig])
 */
      __pyx_t_10 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__sum); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_v_length);
      __pyx_v_length = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "GatEngine.pyx":3021
 *             for contig, segmentlist in vv.iteritems():
 *                 length = segmentlist.sum()
 *                 if length == 0: continue             # <<<<<<<<<<<<<<
 *                 overlap = segmentlist.overlapWithSegments(other[contig])
 *                 outfile.write( "\t".join( \
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_length, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_12) {
        goto __pyx_L5_continue;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "GatEngine.pyx":3022
 *                 length = segmentlist.sum()
 *                 if length == 0: continue
 *                 overlap = segmentlist.overlapWithSegments(other[contig])             # <<<<<<<<<<<<<<
 *                 outfile.write( "\t".join( \
 *                         (self.name, track, contig,
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_segmentlist, __pyx_n_s__overlapWithSegments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = PyObject_GetItem(__pyx_v_other, __pyx_v_contig); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_v_overlap);
      __pyx_v_overlap = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "GatEngine.pyx":3023
 *                 if length == 0: continue
 *                 overlap = segmentlist.overlapWithSegments(other[contig])
 *                 outfile.write( "\t".join( \             # <<<<<<<<<<<<<<
 *                         (self.name, track, contig,
 *                          "%i" % overlap,
 */
      __pyx_t_10 = PyObject_GetAttr(__pyx_v_outfile, __pyx_n_s__write); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);

      /* "GatEngine.pyx":3027
 *                          "%i" % overlap,
 *                          "%i" % length,
 *                          "%f" % (float(overlap) / length)) ) + "\n" )             # <<<<<<<<<<<<<<
 * 
 * def buildIntervalCollection( *args ):
 */
      __pyx_t_13 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_28), __pyx_n_s__join); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);

      /* "GatEngine.pyx":3025
 *                 outfile.write( "\t".join( \
 *                         (self.name, track, contig,
 *                          "%i" % overlap,             # <<<<<<<<<<<<<<
 *                          "%i" % length,
 *                          "%f" % (float(overlap) / length)) ) + "\n" )
 */
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_v_overlap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));

      /* "GatEngine.pyx":3026
 *                         (self.name, track, contig,
 *                          "%i" % overlap,
 *                          "%i" % length,             # <<<<<<<<<<<<<<
 *                          "%f" % (float(overlap) / length)) ) + "\n" )
 * 
 */
      __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_v_length); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_14));

      /* "GatEngine.pyx":3027
 *                          "%i" % overlap,
 *                          "%i" % length,
 *                          "%f" % (float(overlap) / length)) ) + "\n" )             # <<<<<<<<<<<<<<
 * 
 * def buildIntervalCollection( *args ):
 */
      __pyx_t_15 = __Pyx_PyObject_AsDouble(__pyx_v_overlap); if (unlikely(__pyx_t_15 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_16 = PyFloat_FromDouble(__pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = __Pyx_PyNumber_Divide(__pyx_t_16, __pyx_v_length); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_94), __pyx_t_17); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_16));
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = PyTuple_New(6); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.name));
      PyTuple_SET_ITEM(__pyx_t_17, 0, ((PyObject *)__pyx_v_self->__pyx_base.name));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.name));
      __Pyx_INCREF(__pyx_v_track);
      PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_v_track);
      __Pyx_GIVEREF(__pyx_v_track);
      __Pyx_INCREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_v_contig);
      __Pyx_GIVEREF(__pyx_v_contig);
      PyTuple_SET_ITEM(__pyx_t_17, 3, ((PyObject *)__pyx_t_1));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
      PyTuple_SET_ITEM(__pyx_t_17, 4, ((PyObject *)__pyx_t_14));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_14));
      PyTuple_SET_ITEM(__pyx_t_17, 5, ((PyObject *)__pyx_t_16));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_16));
      __pyx_t_1 = 0;
      __pyx_t_14 = 0;
      __pyx_t_16 = 0;
      __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_16, 0, ((PyObject *)__pyx_t_17));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_17));
      __pyx_t_17 = 0;
      __pyx_t_17 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_t_16), NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_16)); __pyx_t_16 = 0;
      __pyx_t_16 = PyNumber_Add(__pyx_t_17, ((PyObject *)__pyx_kp_s_87)); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = PyTuple_New(1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      __pyx_t_16 = 0;
      __pyx_t_16 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_17), NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_17)); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_L5_continue:;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("GatEngine.IntervalCollection.outputOverlapStats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF(__pyx_v_vv);
  __Pyx_XDECREF(__pyx_v_contig);
  __Pyx_XDECREF(__pyx_v_segmentlist);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XDECREF(__pyx_v_overlap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_39buildIntervalCollection(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_38buildIntervalCollection[] = "buildIntervalCollection(*args)\nunpickling - return a rebuilt SamplerShift object.";
static PyMethodDef __pyx_mdef_9GatEngine_39buildIntervalCollection = {__Pyx_NAMESTR("buildIntervalCollection"), (PyCFunction)__pyx_pw_9GatEngine_39buildIntervalCollection, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_38buildIntervalCollection)};
static PyObject *__pyx_pw_9GatEngine_39buildIntervalCollection(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buildIntervalCollection (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "buildIntervalCollection", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_9GatEngine_38buildIntervalCollection(__pyx_self, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3029
 *                          "%f" % (float(overlap) / length)) ) + "\n" )
 * 
 * def buildIntervalCollection( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )
 */

static PyObject *__pyx_pf_9GatEngine_38buildIntervalCollection(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buildIntervalCollection", 0);

  /* "GatEngine.pyx":3031
 * def buildIntervalCollection( *args ):
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )             # <<<<<<<<<<<<<<
 * 
 * #####################################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__unreduce), ((PyObject *)__pyx_v_args)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalCollection)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.buildIntervalCollection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_7Samples_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_7Samples___init__[] = "create a new SampleCollection.\n\n        If cache is given, samples will be stored persistently on disk.\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_7Samples___init__;
#endif
static int __pyx_pw_9GatEngine_7Samples_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_9GatEngine_7Samples___init__(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3045
 *     cdef dict samples
 * 
 *     def __init__(self ):             # <<<<<<<<<<<<<<
 *         '''create a new SampleCollection.
 * 
 */

static int __pyx_pf_9GatEngine_7Samples___init__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":3050
 *         If cache is given, samples will be stored persistently on disk.
 *         '''
 *         self.samples = {}             # <<<<<<<<<<<<<<
 * 
 *     def add( self, track, sample_id, isochore, segmentlist ):
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->samples);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->samples));
  __pyx_v_self->samples = __pyx_t_1;
  __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.Samples.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_7Samples_3add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_7Samples_2add[] = "Samples.add(self, track, sample_id, isochore, segmentlist)\nadd a new *sample* for *track* and *isochore*, giving it *sample_id*.";
static PyObject *__pyx_pw_9GatEngine_7Samples_3add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_sample_id = 0;
  PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,&__pyx_n_s__segmentlist,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segmentlist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
    __pyx_v_segmentlist = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.Samples.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_7Samples_2add(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore, __pyx_v_segmentlist);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3052
 *         self.samples = {}
 * 
 *     def add( self, track, sample_id, isochore, segmentlist ):             # <<<<<<<<<<<<<<
 *         '''add a new *sample* for *track* and *isochore*, giving it *sample_id*.'''
 *         if track not in self.samples:
 */

static PyObject *__pyx_pf_9GatEngine_7Samples_2add(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore, PyObject *__pyx_v_segmentlist) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);

  /* "GatEngine.pyx":3054
 *     def add( self, track, sample_id, isochore, segmentlist ):
 *         '''add a new *sample* for *track* and *isochore*, giving it *sample_id*.'''
 *         if track not in self.samples:             # <<<<<<<<<<<<<<
 *             self.samples[track] = IntervalCollection( track )
 *         self.samples[track].add( sample_id, isochore, segmentlist )
 */
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = (__Pyx_PyDict_Contains(__pyx_v_track, ((PyObject *)__pyx_v_self->samples), Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "GatEngine.pyx":3055
 *         '''add a new *sample* for *track* and *isochore*, giving it *sample_id*.'''
 *         if track not in self.samples:
 *             self.samples[track] = IntervalCollection( track )             # <<<<<<<<<<<<<<
 *         self.samples[track].add( sample_id, isochore, segmentlist )
 * 
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_track);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_track);
    __Pyx_GIVEREF(__pyx_v_track);
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalCollection)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (PyDict_SetItem(((PyObject *)__pyx_v_self->samples), __pyx_v_track, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":3056
 *         if track not in self.samples:
 *             self.samples[track] = IntervalCollection( track )
 *         self.samples[track].add( sample_id, isochore, segmentlist )             # <<<<<<<<<<<<<<
 * 
 *     def hasSample( self, track, sample_id, isochore ):
 */
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->samples), __pyx_v_track); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __Pyx_INCREF(__pyx_v_segmentlist);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_segmentlist);
  __Pyx_GIVEREF(__pyx_v_segmentlist);
  __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 = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("GatEngine.Samples.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_7Samples_5hasSample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_7Samples_4hasSample[] = "Samples.hasSample(self, track, sample_id, isochore)\nreturn true if cache has sample.";
static PyObject *__pyx_pw_9GatEngine_7Samples_5hasSample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_sample_id = 0;
  PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("hasSample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hasSample", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hasSample", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hasSample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("hasSample", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.Samples.hasSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_7Samples_4hasSample(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3058
 *         self.samples[track].add( sample_id, isochore, segmentlist )
 * 
 *     def hasSample( self, track, sample_id, isochore ):             # <<<<<<<<<<<<<<
 *         '''return true if cache has sample.'''
 *         if track not in self.samples: return False
 */

static PyObject *__pyx_pf_9GatEngine_7Samples_4hasSample(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("hasSample", 0);

  /* "GatEngine.pyx":3060
 *     def hasSample( self, track, sample_id, isochore ):
 *         '''return true if cache has sample.'''
 *         if track not in self.samples: return False             # <<<<<<<<<<<<<<
 *         if sample_id not in self.samples[track]: return False
 *         return isochore in self.samples[track][sample_id]
 */
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = (__Pyx_PyDict_Contains(__pyx_v_track, ((PyObject *)__pyx_v_self->samples), Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":3061
 *         '''return true if cache has sample.'''
 *         if track not in self.samples: return False
 *         if sample_id not in self.samples[track]: return False             # <<<<<<<<<<<<<<
 *         return isochore in self.samples[track][sample_id]
 * 
 */
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->samples), __pyx_v_track); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_sample_id, __pyx_t_2, Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "GatEngine.pyx":3062
 *         if track not in self.samples: return False
 *         if sample_id not in self.samples[track]: return False
 *         return isochore in self.samples[track][sample_id]             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, track ):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->samples), __pyx_v_track); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_sample_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_isochore, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.Samples.hasSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_7Samples_7__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_track); /*proto*/
static int __pyx_pw_9GatEngine_7Samples_7__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_track) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_7Samples_6__contains__(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self), ((PyObject *)__pyx_v_track));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3064
 *         return isochore in self.samples[track][sample_id]
 * 
 *     def __contains__(self, track ):             # <<<<<<<<<<<<<<
 *         return track in self.samples
 * 
 */

static int __pyx_pf_9GatEngine_7Samples_6__contains__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "GatEngine.pyx":3065
 * 
 *     def __contains__(self, track ):
 *         return track in self.samples             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, track ):
 */
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = (__Pyx_PyDict_Contains(__pyx_v_track, ((PyObject *)__pyx_v_self->samples), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("GatEngine.Samples.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_7Samples_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_track); /*proto*/
static char __pyx_doc_9GatEngine_7Samples_8__getitem__[] = "return all samples for track (as an :class:`IntervalCollection`)";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_7Samples_8__getitem__;
#endif
static PyObject *__pyx_pw_9GatEngine_7Samples_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_track) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_7Samples_8__getitem__(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self), ((PyObject *)__pyx_v_track));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3067
 *         return track in self.samples
 * 
 *     def __getitem__(self, track ):             # <<<<<<<<<<<<<<
 *         '''return all samples for track (as an :class:`IntervalCollection`)'''
 *         return self.samples[track]
 */

static PyObject *__pyx_pf_9GatEngine_7Samples_8__getitem__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_track) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "GatEngine.pyx":3069
 *     def __getitem__(self, track ):
 *         '''return all samples for track (as an :class:`IntervalCollection`)'''
 *         return self.samples[track]             # <<<<<<<<<<<<<<
 * 
 *     def load( self, track, sample_id, isochore ):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->samples), __pyx_v_track); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.Samples.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_7Samples_11load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_7Samples_10load[] = "Samples.load(self, track, sample_id, isochore)";
static PyObject *__pyx_pw_9GatEngine_7Samples_11load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_track = 0;
  CYTHON_UNUSED PyObject *__pyx_v_sample_id = 0;
  CYTHON_UNUSED PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "load") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.Samples.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_7Samples_10load(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3071
 *         return self.samples[track]
 * 
 *     def load( self, track, sample_id, isochore ):             # <<<<<<<<<<<<<<
 *         raise ValueError( "loading called for uncached data" )
 * 
 */

static PyObject *__pyx_pf_9GatEngine_7Samples_10load(CYTHON_UNUSED struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_track, CYTHON_UNUSED PyObject *__pyx_v_sample_id, CYTHON_UNUSED PyObject *__pyx_v_isochore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load", 0);

  /* "GatEngine.pyx":3072
 * 
 *     def load( self, track, sample_id, isochore ):
 *         raise ValueError( "loading called for uncached data" )             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key ):
 */
  __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_96), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.Samples.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_7Samples_13__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_9GatEngine_7Samples_13__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_7Samples_12__delitem__(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3074
 *         raise ValueError( "loading called for uncached data" )
 * 
 *     def __delitem__(self, key ):             # <<<<<<<<<<<<<<
 *         E.debug("releasing memory for sample %s" % key )
 *         del self.samples[key]
 */

static int __pyx_pf_9GatEngine_7Samples_12__delitem__(CYTHON_UNUSED struct __pyx_obj_9GatEngine_Samples *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delitem__", 0);

  /* "GatEngine.pyx":3075
 * 
 *     def __delitem__(self, key ):
 *         E.debug("releasing memory for sample %s" % key )             # <<<<<<<<<<<<<<
 *         del self.samples[key]
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_97), __pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":3076
 *     def __delitem__(self, key ):
 *         E.debug("releasing memory for sample %s" % key )
 *         del self.samples[key]             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  if (unlikely(((PyObject *)__pyx_v_self->samples) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (PyDict_DelItem(((PyObject *)__pyx_v_self->samples), __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.Samples.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static Py_ssize_t __pyx_pw_9GatEngine_7Samples_15__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_9GatEngine_7Samples_15__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_7Samples_14__len__(((struct __pyx_obj_9GatEngine_Samples *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3078
 *         del self.samples[key]
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.samples)
 * 
 */

static Py_ssize_t __pyx_pf_9GatEngine_7Samples_14__len__(struct __pyx_obj_9GatEngine_Samples *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "GatEngine.pyx":3079
 * 
 *     def __len__(self):
 *         return len(self.samples)             # <<<<<<<<<<<<<<
 * 
 * cdef class SamplesFile( Samples ):
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->samples);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyDict_Size(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.Samples.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_11SamplesFile_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_11SamplesFile___init__[] = "create a new SampleCollection.\n        \n        Samples are read from *filenames* at startup.\n        The track name is given by applying the regular\n        expression to the pattern.\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_11SamplesFile___init__;
#endif
static int __pyx_pw_9GatEngine_11SamplesFile_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filenames = 0;
  PyObject *__pyx_v_regex = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filenames,&__pyx_n_s__regex,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filenames)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__regex)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_filenames = values[0];
    __pyx_v_regex = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_11SamplesFile___init__(((struct __pyx_obj_9GatEngine_SamplesFile *)__pyx_v_self), __pyx_v_filenames, __pyx_v_regex);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3086
 *     Samples :class:`IntervalCollections` identified by track and sample_id.
 *     '''
 *     def __init__(self, filenames, regex ):             # <<<<<<<<<<<<<<
 *         '''create a new SampleCollection.
 * 
 */

static int __pyx_pf_9GatEngine_11SamplesFile___init__(struct __pyx_obj_9GatEngine_SamplesFile *__pyx_v_self, PyObject *__pyx_v_filenames, PyObject *__pyx_v_regex) {
  PyObject *__pyx_v_filename = NULL;
  PyObject *__pyx_v_track = NULL;
  struct __pyx_obj_9GatEngine_IntervalCollection *__pyx_v_s = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":3093
 *         expression to the pattern.
 *         '''
 *         Samples.__init__(self)             # <<<<<<<<<<<<<<
 * 
 *         for filename in filenames:
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_Samples)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __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 = 3093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":3095
 *         Samples.__init__(self)
 * 
 *         for filename in filenames:             # <<<<<<<<<<<<<<
 *             track = regex.search(filename).groups()[0]
 *             s = IntervalCollection( track )
 */
  if (PyList_CheckExact(__pyx_v_filenames) || PyTuple_CheckExact(__pyx_v_filenames)) {
    __pyx_t_3 = __pyx_v_filenames; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_filenames); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_filename);
    __pyx_v_filename = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "GatEngine.pyx":3096
 * 
 *         for filename in filenames:
 *             track = regex.search(filename).groups()[0]             # <<<<<<<<<<<<<<
 *             s = IntervalCollection( track )
 *             s.load( filename )
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_regex, __pyx_n_s__search); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__groups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_v_track);
    __pyx_v_track = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "GatEngine.pyx":3097
 *         for filename in filenames:
 *             track = regex.search(filename).groups()[0]
 *             s = IntervalCollection( track )             # <<<<<<<<<<<<<<
 *             s.load( filename )
 *             self.samples[track] = s
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_track);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_track);
    __Pyx_GIVEREF(__pyx_v_track);
    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_IntervalCollection)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_s));
    __pyx_v_s = ((struct __pyx_obj_9GatEngine_IntervalCollection *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "GatEngine.pyx":3098
 *             track = regex.search(filename).groups()[0]
 *             s = IntervalCollection( track )
 *             s.load( filename )             # <<<<<<<<<<<<<<
 *             self.samples[track] = s
 * 
 */
    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_s), __pyx_n_s__load); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "GatEngine.pyx":3099
 *             s = IntervalCollection( track )
 *             s.load( filename )
 *             self.samples[track] = s             # <<<<<<<<<<<<<<
 * 
 *     def load( self, track, sample_id, isochore ):
 */
    if (unlikely(((PyObject *)__pyx_v_self->__pyx_base.samples) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (PyDict_SetItem(((PyObject *)__pyx_v_self->__pyx_base.samples), __pyx_v_track, ((PyObject *)__pyx_v_s)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("GatEngine.SamplesFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XDECREF(__pyx_v_track);
  __Pyx_XDECREF((PyObject *)__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_11SamplesFile_3load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_11SamplesFile_2load[] = "SamplesFile.load(self, track, sample_id, isochore)";
static PyObject *__pyx_pw_9GatEngine_11SamplesFile_3load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_track = 0;
  CYTHON_UNUSED PyObject *__pyx_v_sample_id = 0;
  CYTHON_UNUSED PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3101; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3101; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "load") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3101; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3101; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesFile.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_11SamplesFile_2load(((struct __pyx_obj_9GatEngine_SamplesFile *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3101
 *             self.samples[track] = s
 * 
 *     def load( self, track, sample_id, isochore ):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static PyObject *__pyx_pf_9GatEngine_11SamplesFile_2load(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplesFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_track, CYTHON_UNUSED PyObject *__pyx_v_sample_id, CYTHON_UNUSED PyObject *__pyx_v_isochore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load", 0);

  /* "GatEngine.pyx":3102
 * 
 *     def load( self, track, sample_id, isochore ):
 *         return True             # <<<<<<<<<<<<<<
 * 
 * cdef class SamplesCached( Samples ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.SamplesFile.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9GatEngine_13SamplesCached_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_13SamplesCached___init__[] = "create a new SampleCollection.\n\n        If cache is given, samples will be stored persistently on disk.\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_9GatEngine_13SamplesCached___init__;
#endif
static int __pyx_pw_9GatEngine_13SamplesCached_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_filename = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesCached.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_13SamplesCached___init__(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self), __pyx_v_filename);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3114
 *     cdef char * filename
 * 
 *     def __init__(self, filename ):             # <<<<<<<<<<<<<<
 *         '''create a new SampleCollection.
 * 
 */

static int __pyx_pf_9GatEngine_13SamplesCached___init__(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_tmp = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "GatEngine.pyx":3119
 *         If cache is given, samples will be stored persistently on disk.
 *         '''
 *         Samples.__init__(self)             # <<<<<<<<<<<<<<
 * 
 *         self.filename = filename
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_Samples)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __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 = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":3121
 *         Samples.__init__(self)
 * 
 *         self.filename = filename             # <<<<<<<<<<<<<<
 *         tmp = self.filename + ".idx"
 * 
 */
  __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->filename = __pyx_t_4;

  /* "GatEngine.pyx":3122
 * 
 *         self.filename = filename
 *         tmp = self.filename + ".idx"             # <<<<<<<<<<<<<<
 * 
 *         if not os.path.exists( filename ):
 */
  __pyx_t_3 = PyBytes_FromString(__pyx_v_self->filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_kp_s_98)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_tmp = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":3124
 *         tmp = self.filename + ".idx"
 * 
 *         if not os.path.exists( filename ):             # <<<<<<<<<<<<<<
 *             self.fcache = fopen( filename, "wb" )
 *             self.findex = fopen( tmp, "wb" )
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (!__pyx_t_5);
  if (__pyx_t_6) {

    /* "GatEngine.pyx":3125
 * 
 *         if not os.path.exists( filename ):
 *             self.fcache = fopen( filename, "wb" )             # <<<<<<<<<<<<<<
 *             self.findex = fopen( tmp, "wb" )
 *             self.index = {}
 */
    __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->fcache = fopen(__pyx_t_4, __pyx_k__wb);

    /* "GatEngine.pyx":3126
 *         if not os.path.exists( filename ):
 *             self.fcache = fopen( filename, "wb" )
 *             self.findex = fopen( tmp, "wb" )             # <<<<<<<<<<<<<<
 *             self.index = {}
 *         else:
 */
    __pyx_t_4 = PyBytes_AsString(__pyx_v_tmp); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->findex = fopen(__pyx_t_4, __pyx_k__wb);

    /* "GatEngine.pyx":3127
 *             self.fcache = fopen( filename, "wb" )
 *             self.findex = fopen( tmp, "wb" )
 *             self.index = {}             # <<<<<<<<<<<<<<
 *         else:
 *             self.fcache = fopen( filename, "rb" )
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __Pyx_GOTREF(__pyx_v_self->index);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
    __pyx_v_self->index = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "GatEngine.pyx":3129
 *             self.index = {}
 *         else:
 *             self.fcache = fopen( filename, "rb" )             # <<<<<<<<<<<<<<
 *             self.loadIndex()
 *             self.findex = fopen( tmp, "rb" )
 */
    __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->fcache = fopen(__pyx_t_4, __pyx_k__rb);

    /* "GatEngine.pyx":3130
 *         else:
 *             self.fcache = fopen( filename, "rb" )
 *             self.loadIndex()             # <<<<<<<<<<<<<<
 *             self.findex = fopen( tmp, "rb" )
 * 
 */
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__loadIndex); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "GatEngine.pyx":3131
 *             self.fcache = fopen( filename, "rb" )
 *             self.loadIndex()
 *             self.findex = fopen( tmp, "rb" )             # <<<<<<<<<<<<<<
 * 
 *     def loadIndex( self ):
 */
    __pyx_t_4 = PyBytes_AsString(__pyx_v_tmp); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->findex = fopen(__pyx_t_4, __pyx_k__rb);
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.SamplesCached.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tmp);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_3loadIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9GatEngine_13SamplesCached_2loadIndex[] = "SamplesCached.loadIndex(self)\nload index from cache.\n\n        The index is loaded from a new file.\n        ";
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_3loadIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("loadIndex (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_13SamplesCached_2loadIndex(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3133
 *             self.findex = fopen( tmp, "rb" )
 * 
 *     def loadIndex( self ):             # <<<<<<<<<<<<<<
 *         '''load index from cache.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_13SamplesCached_2loadIndex(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self) {
  char *__pyx_v_ckey;
  off_t __pyx_v_pos;
  char __pyx_v_keylen;
  FILE *__pyx_v_findex;
  PyObject *__pyx_v_tmp = NULL;
  CYTHON_UNUSED long __pyx_v_x;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("loadIndex", 0);

  /* "GatEngine.pyx":3138
 *         The index is loaded from a new file.
 *         '''
 *         E.debug( "loading index from %s" % self.filename )             # <<<<<<<<<<<<<<
 *         cdef char * ckey
 *         cdef off_t pos
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyBytes_FromString(__pyx_v_self->filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_99), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":3143
 *         cdef char keylen
 *         cdef FILE * findex
 *         self.index = {}             # <<<<<<<<<<<<<<
 *         tmp = self.filename + ".idx"
 *         findex = fopen( tmp, "rb" )
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __Pyx_GOTREF(__pyx_v_self->index);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->index));
  __pyx_v_self->index = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":3144
 *         cdef FILE * findex
 *         self.index = {}
 *         tmp = self.filename + ".idx"             # <<<<<<<<<<<<<<
 *         findex = fopen( tmp, "rb" )
 * 
 */
  __pyx_t_3 = PyBytes_FromString(__pyx_v_self->filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_kp_s_98)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_tmp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":3145
 *         self.index = {}
 *         tmp = self.filename + ".idx"
 *         findex = fopen( tmp, "rb" )             # <<<<<<<<<<<<<<
 * 
 *         ckey = <char*>calloc( sizeof(char) * 256, 1 )
 */
  __pyx_t_4 = PyBytes_AsString(__pyx_v_tmp); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_findex = fopen(__pyx_t_4, __pyx_k__rb);

  /* "GatEngine.pyx":3147
 *         findex = fopen( tmp, "rb" )
 * 
 *         ckey = <char*>calloc( sizeof(char) * 256, 1 )             # <<<<<<<<<<<<<<
 *         x = 0
 *         while not feof( findex ):
 */
  __pyx_v_ckey = ((char *)calloc(((sizeof(char)) * 256), 1));

  /* "GatEngine.pyx":3148
 * 
 *         ckey = <char*>calloc( sizeof(char) * 256, 1 )
 *         x = 0             # <<<<<<<<<<<<<<
 *         while not feof( findex ):
 *             fread( &keylen, sizeof( char), 1, findex )
 */
  __pyx_v_x = 0;

  /* "GatEngine.pyx":3149
 *         ckey = <char*>calloc( sizeof(char) * 256, 1 )
 *         x = 0
 *         while not feof( findex ):             # <<<<<<<<<<<<<<
 *             fread( &keylen, sizeof( char), 1, findex )
 *             if feof(findex): break
 */
  while (1) {
    __pyx_t_5 = (!feof(__pyx_v_findex));
    if (!__pyx_t_5) break;

    /* "GatEngine.pyx":3150
 *         x = 0
 *         while not feof( findex ):
 *             fread( &keylen, sizeof( char), 1, findex )             # <<<<<<<<<<<<<<
 *             if feof(findex): break
 *             fread( ckey, sizeof( char), keylen, findex )
 */
    fread((&__pyx_v_keylen), (sizeof(char)), 1, __pyx_v_findex);

    /* "GatEngine.pyx":3151
 *         while not feof( findex ):
 *             fread( &keylen, sizeof( char), 1, findex )
 *             if feof(findex): break             # <<<<<<<<<<<<<<
 *             fread( ckey, sizeof( char), keylen, findex )
 *             fread( &pos, sizeof(off_t), 1, findex )
 */
    __pyx_t_6 = feof(__pyx_v_findex);
    if (__pyx_t_6) {
      goto __pyx_L4_break;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "GatEngine.pyx":3152
 *             fread( &keylen, sizeof( char), 1, findex )
 *             if feof(findex): break
 *             fread( ckey, sizeof( char), keylen, findex )             # <<<<<<<<<<<<<<
 *             fread( &pos, sizeof(off_t), 1, findex )
 *             # converts to persistent python object
 */
    fread(__pyx_v_ckey, (sizeof(char)), __pyx_v_keylen, __pyx_v_findex);

    /* "GatEngine.pyx":3153
 *             if feof(findex): break
 *             fread( ckey, sizeof( char), keylen, findex )
 *             fread( &pos, sizeof(off_t), 1, findex )             # <<<<<<<<<<<<<<
 *             # converts to persistent python object
 *             self.index[ckey] = pos
 */
    fread((&__pyx_v_pos), (sizeof(off_t)), 1, __pyx_v_findex);

    /* "GatEngine.pyx":3155
 *             fread( &pos, sizeof(off_t), 1, findex )
 *             # converts to persistent python object
 *             self.index[ckey] = pos             # <<<<<<<<<<<<<<
 * 
 *         fclose(findex)
 */
    __pyx_t_1 = __Pyx_PyInt_to_py_off_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(((PyObject *)__pyx_v_self->index) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = PyBytes_FromString(__pyx_v_ckey); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    if (PyDict_SetItem(((PyObject *)__pyx_v_self->index), ((PyObject *)__pyx_t_3), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L4_break:;

  /* "GatEngine.pyx":3157
 *             self.index[ckey] = pos
 * 
 *         fclose(findex)             # <<<<<<<<<<<<<<
 *         free(ckey)
 * 
 */
  fclose(__pyx_v_findex);

  /* "GatEngine.pyx":3158
 * 
 *         fclose(findex)
 *         free(ckey)             # <<<<<<<<<<<<<<
 * 
 *         E.debug( "loaded index from %s: %i items" % (self.filename,len(self.index) ))
 */
  free(__pyx_v_ckey);

  /* "GatEngine.pyx":3160
 *         free(ckey)
 * 
 *         E.debug( "loaded index from %s: %i items" % (self.filename,len(self.index) ))             # <<<<<<<<<<<<<<
 * 
 *     def add( self, track, sample_id, isochore, segmentlist ):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyBytes_FromString(__pyx_v_self->filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = ((PyObject *)__pyx_v_self->index);
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(__pyx_t_2 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = PyDict_Size(__pyx_t_2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_100), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("GatEngine.SamplesCached.loadIndex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tmp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_13SamplesCached_4add[] = "SamplesCached.add(self, track, sample_id, isochore, segmentlist)\nadd a new *sample* for *track* and *isochore*, giving it *sample_id*.";
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_5add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_sample_id = 0;
  PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_v_segmentlist = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,&__pyx_n_s__segmentlist,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3162; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3162; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__segmentlist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3162; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3162; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
    __pyx_v_segmentlist = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3162; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesCached.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_13SamplesCached_4add(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore, __pyx_v_segmentlist);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3162
 *         E.debug( "loaded index from %s: %i items" % (self.filename,len(self.index) ))
 * 
 *     def add( self, track, sample_id, isochore, segmentlist ):             # <<<<<<<<<<<<<<
 *         '''add a new *sample* for *track* and *isochore*, giving it *sample_id*.'''
 * 
 */

static PyObject *__pyx_pf_9GatEngine_13SamplesCached_4add(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore, PyObject *__pyx_v_segmentlist) {
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_seglist = 0;
  off_t __pyx_v_pos;
  char *__pyx_v_key;
  char __pyx_v_keylen;
  PyObject *__pyx_v_l = NULL;
  PyObject *__pyx_v_tempkey = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  char *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);

  /* "GatEngine.pyx":3165
 *         '''add a new *sample* for *track* and *isochore*, giving it *sample_id*.'''
 * 
 *         Samples.add( self, track, sample_id, isochore, segmentlist )             # <<<<<<<<<<<<<<
 * 
 *         cdef SegmentList seglist
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_Samples)), __pyx_n_s__add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __Pyx_INCREF(__pyx_v_segmentlist);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_v_segmentlist);
  __Pyx_GIVEREF(__pyx_v_segmentlist);
  __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 = 3165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "GatEngine.pyx":3168
 * 
 *         cdef SegmentList seglist
 *         seglist = segmentlist             # <<<<<<<<<<<<<<
 *         cdef off_t pos
 *         cdef char * key
 */
  if (!(likely(((__pyx_v_segmentlist) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_segmentlist, __pyx_ptype_14GatSegmentList_SegmentList))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_segmentlist);
  __pyx_v_seglist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_v_segmentlist);

  /* "GatEngine.pyx":3173
 *         cdef char keylen
 * 
 *         l = len(seglist)             # <<<<<<<<<<<<<<
 *         if l == 0: return
 * 
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_seglist)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_l = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":3174
 * 
 *         l = len(seglist)
 *         if l == 0: return             # <<<<<<<<<<<<<<
 * 
 *         pos = ftello( self.fcache )
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_l, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":3176
 *         if l == 0: return
 * 
 *         pos = ftello( self.fcache )             # <<<<<<<<<<<<<<
 * 
 *         # cache structure is:
 */
  __pyx_v_pos = ftello(__pyx_v_self->fcache);

  /* "GatEngine.pyx":3182
 *         # 1 * sizeof(Position) - number of segments (nsegments)
 *         # nsegments * sizeof(Segment) - the segment list
 *         tempkey = self.toKey( track, sample_id, isochore )             # <<<<<<<<<<<<<<
 *         assert len(tempkey) <= 255
 *         key = tempkey
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__toKey); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_tempkey = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":3183
 *         # nsegments * sizeof(Segment) - the segment list
 *         tempkey = self.toKey( track, sample_id, isochore )
 *         assert len(tempkey) <= 255             # <<<<<<<<<<<<<<
 *         key = tempkey
 *         keylen = strlen( key ) + 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  __pyx_t_4 = PyObject_Length(__pyx_v_tempkey); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!(__pyx_t_4 <= 255))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "GatEngine.pyx":3184
 *         tempkey = self.toKey( track, sample_id, isochore )
 *         assert len(tempkey) <= 255
 *         key = tempkey             # <<<<<<<<<<<<<<
 *         keylen = strlen( key ) + 1
 * 
 */
  __pyx_t_6 = PyBytes_AsString(__pyx_v_tempkey); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_key = __pyx_t_6;

  /* "GatEngine.pyx":3185
 *         assert len(tempkey) <= 255
 *         key = tempkey
 *         keylen = strlen( key ) + 1             # <<<<<<<<<<<<<<
 * 
 *         self.index[ key ] = pos
 */
  __pyx_v_keylen = (strlen(__pyx_v_key) + 1);

  /* "GatEngine.pyx":3187
 *         keylen = strlen( key ) + 1
 * 
 *         self.index[ key ] = pos             # <<<<<<<<<<<<<<
 * 
 *         fwrite( &seglist.nsegments, sizeof( Position ), 1, self.fcache )
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_off_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(((PyObject *)__pyx_v_self->index) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->index), ((PyObject *)__pyx_t_2), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":3189
 *         self.index[ key ] = pos
 * 
 *         fwrite( &seglist.nsegments, sizeof( Position ), 1, self.fcache )             # <<<<<<<<<<<<<<
 *         toCompressedFile( <unsigned char *>seglist.segments,
 *                           sizeof( Segment) * seglist.nsegments,
 */
  fwrite((&__pyx_v_seglist->nsegments), (sizeof(__pyx_t_14GatSegmentList_Position)), 1, __pyx_v_self->fcache);

  /* "GatEngine.pyx":3192
 *         toCompressedFile( <unsigned char *>seglist.segments,
 *                           sizeof( Segment) * seglist.nsegments,
 *                           self.fcache )             # <<<<<<<<<<<<<<
 * 
 *         # write to index
 */
  toCompressedFile(((unsigned char *)__pyx_v_seglist->segments), ((sizeof(struct __pyx_t_14GatSegmentList_Segment)) * __pyx_v_seglist->nsegments), __pyx_v_self->fcache);

  /* "GatEngine.pyx":3195
 * 
 *         # write to index
 *         fwrite( &keylen, sizeof(char), 1, self.findex )             # <<<<<<<<<<<<<<
 *         fwrite( key, sizeof(char), keylen, self.findex )
 *         fwrite( &pos, sizeof(off_t), 1, self.findex )
 */
  fwrite((&__pyx_v_keylen), (sizeof(char)), 1, __pyx_v_self->findex);

  /* "GatEngine.pyx":3196
 *         # write to index
 *         fwrite( &keylen, sizeof(char), 1, self.findex )
 *         fwrite( key, sizeof(char), keylen, self.findex )             # <<<<<<<<<<<<<<
 *         fwrite( &pos, sizeof(off_t), 1, self.findex )
 * 
 */
  fwrite(__pyx_v_key, (sizeof(char)), __pyx_v_keylen, __pyx_v_self->findex);

  /* "GatEngine.pyx":3197
 *         fwrite( &keylen, sizeof(char), 1, self.findex )
 *         fwrite( key, sizeof(char), keylen, self.findex )
 *         fwrite( &pos, sizeof(off_t), 1, self.findex )             # <<<<<<<<<<<<<<
 * 
 *     def toKey( self, track, sample_id, isochore ):
 */
  fwrite((&__pyx_v_pos), (sizeof(off_t)), 1, __pyx_v_self->findex);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.SamplesCached.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_seglist);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XDECREF(__pyx_v_tempkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_7toKey(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_13SamplesCached_6toKey[] = "SamplesCached.toKey(self, track, sample_id, isochore)";
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_7toKey(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_sample_id = 0;
  PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("toKey (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("toKey", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("toKey", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "toKey") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("toKey", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesCached.toKey", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_13SamplesCached_6toKey(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3199
 *         fwrite( &pos, sizeof(off_t), 1, self.findex )
 * 
 *     def toKey( self, track, sample_id, isochore ):             # <<<<<<<<<<<<<<
 *         return "%s-%s-%s" % (track,sample_id,isochore)
 * 
 */

static PyObject *__pyx_pf_9GatEngine_13SamplesCached_6toKey(CYTHON_UNUSED struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("toKey", 0);

  /* "GatEngine.pyx":3200
 * 
 *     def toKey( self, track, sample_id, isochore ):
 *         return "%s-%s-%s" % (track,sample_id,isochore)             # <<<<<<<<<<<<<<
 * 
 *     def hasSample( self, track, sample_id, isochore ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_101), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("GatEngine.SamplesCached.toKey", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_9hasSample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_13SamplesCached_8hasSample[] = "SamplesCached.hasSample(self, track, sample_id, isochore)\nreturn true if cache has sample.";
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_9hasSample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_sample_id = 0;
  PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("hasSample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hasSample", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hasSample", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hasSample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("hasSample", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesCached.hasSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_13SamplesCached_8hasSample(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3202
 *         return "%s-%s-%s" % (track,sample_id,isochore)
 * 
 *     def hasSample( self, track, sample_id, isochore ):             # <<<<<<<<<<<<<<
 *         '''return true if cache has sample.'''
 *         return self.toKey( track, sample_id, isochore ) in self.index
 */

static PyObject *__pyx_pf_9GatEngine_13SamplesCached_8hasSample(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("hasSample", 0);

  /* "GatEngine.pyx":3204
 *     def hasSample( self, track, sample_id, isochore ):
 *         '''return true if cache has sample.'''
 *         return self.toKey( track, sample_id, isochore ) in self.index             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__toKey); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __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 = 3204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (unlikely(((PyObject *)__pyx_v_self->index) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_t_3, ((PyObject *)__pyx_v_self->index), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.SamplesCached.hasSample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_9GatEngine_13SamplesCached_11__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_9GatEngine_13SamplesCached_11__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_9GatEngine_13SamplesCached_10__dealloc__(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "GatEngine.pyx":3206
 *         return self.toKey( track, sample_id, isochore ) in self.index
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         fclose( self.fcache )
 *         fclose( self.findex )
 */

static void __pyx_pf_9GatEngine_13SamplesCached_10__dealloc__(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "GatEngine.pyx":3207
 * 
 *     def __dealloc__(self):
 *         fclose( self.fcache )             # <<<<<<<<<<<<<<
 *         fclose( self.findex )
 * 
 */
  fclose(__pyx_v_self->fcache);

  /* "GatEngine.pyx":3208
 *     def __dealloc__(self):
 *         fclose( self.fcache )
 *         fclose( self.findex )             # <<<<<<<<<<<<<<
 * 
 *     def load( self, track, sample_id, isochore ):
 */
  fclose(__pyx_v_self->findex);

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_13load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9GatEngine_13SamplesCached_12load[] = "SamplesCached.load(self, track, sample_id, isochore)\nload data into memory";
static PyObject *__pyx_pw_9GatEngine_13SamplesCached_13load(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_sample_id = 0;
  PyObject *__pyx_v_isochore = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__track,&__pyx_n_s__sample_id,&__pyx_n_s__isochore,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3210; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isochore)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3210; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "load") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3210; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_track = values[0];
    __pyx_v_sample_id = values[1];
    __pyx_v_isochore = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("load", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3210; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("GatEngine.SamplesCached.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9GatEngine_13SamplesCached_12load(((struct __pyx_obj_9GatEngine_SamplesCached *)__pyx_v_self), __pyx_v_track, __pyx_v_sample_id, __pyx_v_isochore);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3210
 *         fclose( self.findex )
 * 
 *     def load( self, track, sample_id, isochore ):             # <<<<<<<<<<<<<<
 *         '''load data into memory'''
 *         cdef off_t pos
 */

static PyObject *__pyx_pf_9GatEngine_13SamplesCached_12load(struct __pyx_obj_9GatEngine_SamplesCached *__pyx_v_self, PyObject *__pyx_v_track, PyObject *__pyx_v_sample_id, PyObject *__pyx_v_isochore) {
  off_t __pyx_v_pos;
  struct __pyx_obj_14GatSegmentList_SegmentList *__pyx_v_seglist = 0;
  __pyx_t_14GatSegmentList_Position __pyx_v_nsegments;
  PyObject *__pyx_v_tempkey = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  off_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load", 0);

  /* "GatEngine.pyx":3216
 *         cdef Position nsegments
 * 
 *         tempkey = self.toKey( track, sample_id, isochore )             # <<<<<<<<<<<<<<
 *         pos = self.index[tempkey]
 *         fseeko( self.fcache, pos, SEEK_SET )
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__toKey); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __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 = 3216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_tempkey = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "GatEngine.pyx":3217
 * 
 *         tempkey = self.toKey( track, sample_id, isochore )
 *         pos = self.index[tempkey]             # <<<<<<<<<<<<<<
 *         fseeko( self.fcache, pos, SEEK_SET )
 *         fread( &nsegments, sizeof(Position), 1, self.fcache )
 */
  if (unlikely(((PyObject *)__pyx_v_self->index) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->index), __pyx_v_tempkey); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_from_py_off_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (off_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_pos = __pyx_t_4;

  /* "GatEngine.pyx":3218
 *         tempkey = self.toKey( track, sample_id, isochore )
 *         pos = self.index[tempkey]
 *         fseeko( self.fcache, pos, SEEK_SET )             # <<<<<<<<<<<<<<
 *         fread( &nsegments, sizeof(Position), 1, self.fcache )
 *         seglist = SegmentList( allocate = nsegments )
 */
  fseeko(__pyx_v_self->fcache, __pyx_v_pos, SEEK_SET);

  /* "GatEngine.pyx":3219
 *         pos = self.index[tempkey]
 *         fseeko( self.fcache, pos, SEEK_SET )
 *         fread( &nsegments, sizeof(Position), 1, self.fcache )             # <<<<<<<<<<<<<<
 *         seglist = SegmentList( allocate = nsegments )
 *         seglist.nsegments = nsegments
 */
  fread((&__pyx_v_nsegments), (sizeof(__pyx_t_14GatSegmentList_Position)), 1, __pyx_v_self->fcache);

  /* "GatEngine.pyx":3220
 *         fseeko( self.fcache, pos, SEEK_SET )
 *         fread( &nsegments, sizeof(Position), 1, self.fcache )
 *         seglist = SegmentList( allocate = nsegments )             # <<<<<<<<<<<<<<
 *         seglist.nsegments = nsegments
 *         fromCompressedFile( <unsigned char*> seglist.segments,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_nsegments); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__allocate), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14GatSegmentList_SegmentList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_seglist = ((struct __pyx_obj_14GatSegmentList_SegmentList *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "GatEngine.pyx":3221
 *         fread( &nsegments, sizeof(Position), 1, self.fcache )
 *         seglist = SegmentList( allocate = nsegments )
 *         seglist.nsegments = nsegments             # <<<<<<<<<<<<<<
 *         fromCompressedFile( <unsigned char*> seglist.segments,
 *                              sizeof( Segment) * seglist.nsegments,
 */
  __pyx_v_seglist->nsegments = __pyx_v_nsegments;

  /* "GatEngine.pyx":3224
 *         fromCompressedFile( <unsigned char*> seglist.segments,
 *                              sizeof( Segment) * seglist.nsegments,
 *                              self.fcache )             # <<<<<<<<<<<<<<
 * 
 *         Samples.add( self, track, sample_id, isochore, seglist )
 */
  fromCompressedFile(((unsigned char *)__pyx_v_seglist->segments), ((sizeof(struct __pyx_t_14GatSegmentList_Segment)) * __pyx_v_seglist->nsegments), __pyx_v_self->fcache);

  /* "GatEngine.pyx":3226
 *                              self.fcache )
 * 
 *         Samples.add( self, track, sample_id, isochore, seglist )             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_9GatEngine_Samples)), __pyx_n_s__add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_track);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_track);
  __Pyx_GIVEREF(__pyx_v_track);
  __Pyx_INCREF(__pyx_v_sample_id);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_sample_id);
  __Pyx_GIVEREF(__pyx_v_sample_id);
  __Pyx_INCREF(__pyx_v_isochore);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_isochore);
  __Pyx_GIVEREF(__pyx_v_isochore);
  __Pyx_INCREF(((PyObject *)__pyx_v_seglist));
  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_v_seglist));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_seglist));
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("GatEngine.SamplesCached.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_seglist);
  __Pyx_XDECREF(__pyx_v_tempkey);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3233
 * ## FDR computation - obsolete
 * ############################################################
 * cdef double computeFalsePositiveRate( EnrichmentStatistics ** allstats,             # <<<<<<<<<<<<<<
 *                                       Position nresults,
 *                                       Position nsamples,
 */

static double __pyx_f_9GatEngine_computeFalsePositiveRate(__pyx_t_9GatEngine_EnrichmentStatistics **__pyx_v_allstats, __pyx_t_14GatSegmentList_Position __pyx_v_nresults, __pyx_t_14GatSegmentList_Position __pyx_v_nsamples, double __pyx_v_pvalue) {
  __pyx_t_14GatSegmentList_Position __pyx_v_y;
  __pyx_t_14GatSegmentList_Position __pyx_v_nsample;
  __pyx_t_14GatSegmentList_Position __pyx_v_nfp;
  __pyx_t_14GatSegmentList_Position __pyx_v_total_nfp;
  double __pyx_v_efp;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  __pyx_t_14GatSegmentList_Position __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("computeFalsePositiveRate", 0);

  /* "GatEngine.pyx":3244
 *     cdef double efp
 * 
 *     total_nfp = 0             # <<<<<<<<<<<<<<
 * 
 *     # Compute for each sample the number of simulated
 */
  __pyx_v_total_nfp = 0;

  /* "GatEngine.pyx":3250
 *     # As there are the same number of "terms" in each sample
 *     # that are tested, a simple summation suffices.
 *     for nsample from 0 <= nsample < nsamples:             # <<<<<<<<<<<<<<
 *         nfp = 0
 *         for y from 0 <= y < nresults:
 */
  __pyx_t_1 = __pyx_v_nsamples;
  for (__pyx_v_nsample = 0; __pyx_v_nsample < __pyx_t_1; __pyx_v_nsample++) {

    /* "GatEngine.pyx":3251
 *     # that are tested, a simple summation suffices.
 *     for nsample from 0 <= nsample < nsamples:
 *         nfp = 0             # <<<<<<<<<<<<<<
 *         for y from 0 <= y < nresults:
 *             if isSampleSignificantAtPvalue( allstats[y], nsample, pvalue ):
 */
    __pyx_v_nfp = 0;

    /* "GatEngine.pyx":3252
 *     for nsample from 0 <= nsample < nsamples:
 *         nfp = 0
 *         for y from 0 <= y < nresults:             # <<<<<<<<<<<<<<
 *             if isSampleSignificantAtPvalue( allstats[y], nsample, pvalue ):
 *                 nfp += 1
 */
    __pyx_t_2 = __pyx_v_nresults;
    for (__pyx_v_y = 0; __pyx_v_y < __pyx_t_2; __pyx_v_y++) {

      /* "GatEngine.pyx":3253
 *         nfp = 0
 *         for y from 0 <= y < nresults:
 *             if isSampleSignificantAtPvalue( allstats[y], nsample, pvalue ):             # <<<<<<<<<<<<<<
 *                 nfp += 1
 *         total_nfp += nfp
 */
      __pyx_t_3 = __pyx_f_9GatEngine_isSampleSignificantAtPvalue((__pyx_v_allstats[__pyx_v_y]), __pyx_v_nsample, __pyx_v_pvalue);
      if (__pyx_t_3) {

        /* "GatEngine.pyx":3254
 *         for y from 0 <= y < nresults:
 *             if isSampleSignificantAtPvalue( allstats[y], nsample, pvalue ):
 *                 nfp += 1             # <<<<<<<<<<<<<<
 *         total_nfp += nfp
 * 
 */
        __pyx_v_nfp = (__pyx_v_nfp + 1);
        goto __pyx_L7;
      }
      __pyx_L7:;
    }

    /* "GatEngine.pyx":3255
 *             if isSampleSignificantAtPvalue( allstats[y], nsample, pvalue ):
 *                 nfp += 1
 *         total_nfp += nfp             # <<<<<<<<<<<<<<
 * 
 *     efp = <double>total_nfp / nsamples
 */
    __pyx_v_total_nfp = (__pyx_v_total_nfp + __pyx_v_nfp);
  }

  /* "GatEngine.pyx":3257
 *         total_nfp += nfp
 * 
 *     efp = <double>total_nfp / nsamples             # <<<<<<<<<<<<<<
 * 
 *     return efp
 */
  if (unlikely(__pyx_v_nsamples == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_efp = (((double)__pyx_v_total_nfp) / __pyx_v_nsamples);

  /* "GatEngine.pyx":3259
 *     efp = <double>total_nfp / nsamples
 * 
 *     return efp             # <<<<<<<<<<<<<<
 * 
 * cpdef computeFDR( annotator_results ):
 */
  __pyx_r = __pyx_v_efp;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("GatEngine.computeFalsePositiveRate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3261
 *     return efp
 * 
 * cpdef computeFDR( annotator_results ):             # <<<<<<<<<<<<<<
 *     '''compute an experimental fdr across all segments and annotations.
 * 
 */

static PyObject *__pyx_pw_9GatEngine_41computeFDR(PyObject *__pyx_self, PyObject *__pyx_v_annotator_results); /*proto*/
static PyObject *__pyx_f_9GatEngine_computeFDR(PyObject *__pyx_v_annotator_results, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_fdr_cache = NULL;
  __pyx_t_14GatSegmentList_Position __pyx_v_nresults;
  struct __pyx_obj_9GatEngine_AnnotatorResult *__pyx_v_r = 0;
  __pyx_t_9GatEngine_EnrichmentStatistics *__pyx_v_r1;
  __pyx_t_9GatEngine_EnrichmentStatistics **__pyx_v_allstats;
  __pyx_t_14GatSegmentList_Position __pyx_v_R;
  __pyx_t_14GatSegmentList_Position __pyx_v_x;
  double __pyx_v_pvalue;
  double __pyx_v_efp;
  PyObject *__pyx_v_all_pvalues = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  __pyx_t_14GatSegmentList_Position __pyx_t_3;
  __pyx_t_9GatEngine_EnrichmentStatistics *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  double __pyx_t_10;
  int __pyx_t_11;
  __pyx_t_14GatSegmentList_Position __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("computeFDR", 0);

  /* "GatEngine.pyx":3277
 *     The results are added to annotator_results.
 *     '''
 *     fdr_cache = {}             # <<<<<<<<<<<<<<
 * 
 *     cdef Position nresults
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_fdr_cache = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "GatEngine.pyx":3288
 *     cdef double pvalue, efp
 * 
 *     nresults = len(annotator_results)             # <<<<<<<<<<<<<<
 * 
 *     # collect results
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_annotator_results); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nresults = __pyx_t_2;

  /* "GatEngine.pyx":3291
 * 
 *     # collect results
 *     allstats = <EnrichmentStatistics **>calloc( nresults, sizeof(EnrichmentStatistics *))             # <<<<<<<<<<<<<<
 * 
 *     for x from 0 <= x < nresults:
 */
  __pyx_v_allstats = ((__pyx_t_9GatEngine_EnrichmentStatistics **)calloc(__pyx_v_nresults, (sizeof(__pyx_t_9GatEngine_EnrichmentStatistics *))));

  /* "GatEngine.pyx":3293
 *     allstats = <EnrichmentStatistics **>calloc( nresults, sizeof(EnrichmentStatistics *))
 * 
 *     for x from 0 <= x < nresults:             # <<<<<<<<<<<<<<
 *         r = annotator_results[x]
 *         allstats[x] = r.stats
 */
  __pyx_t_3 = __pyx_v_nresults;
  for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {

    /* "GatEngine.pyx":3294
 * 
 *     for x from 0 <= x < nresults:
 *         r = annotator_results[x]             # <<<<<<<<<<<<<<
 *         allstats[x] = r.stats
 * 
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_annotator_results, __pyx_v_x, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9GatEngine_AnnotatorResult))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_r));
    __pyx_v_r = ((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "GatEngine.pyx":3295
 *     for x from 0 <= x < nresults:
 *         r = annotator_results[x]
 *         allstats[x] = r.stats             # <<<<<<<<<<<<<<
 * 
 *     all_pvalues = numpy.array( [ r.stats.pvalue for r in annotator_results ], dtype = numpy.float )
 */
    __pyx_t_4 = __pyx_v_r->stats;
    (__pyx_v_allstats[__pyx_v_x]) = __pyx_t_4;
  }

  /* "GatEngine.pyx":3297
 *         allstats[x] = r.stats
 * 
 *     all_pvalues = numpy.array( [ r.stats.pvalue for r in annotator_results ], dtype = numpy.float )             # <<<<<<<<<<<<<<
 *     all_pvalues.sort()
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyList_CheckExact(__pyx_v_annotator_results) || PyTuple_CheckExact(__pyx_v_annotator_results)) {
    __pyx_t_6 = __pyx_v_annotator_results; __Pyx_INCREF(__pyx_t_6); __pyx_t_2 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_annotator_results); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_6)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_8); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_6)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_8); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_8 = __pyx_t_7(__pyx_t_6);
      if (unlikely(!__pyx_t_8)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_9GatEngine_AnnotatorResult))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_r));
    __pyx_v_r = ((struct __pyx_obj_9GatEngine_AnnotatorResult *)__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyFloat_FromDouble(__pyx_v_r->stats->pvalue); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (unlikely(__Pyx_PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__float); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_all_pvalues = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "GatEngine.pyx":3298
 * 
 *     all_pvalues = numpy.array( [ r.stats.pvalue for r in annotator_results ], dtype = numpy.float )
 *     all_pvalues.sort()             # <<<<<<<<<<<<<<
 * 
 *     for x from 0 <= x < nresults:
 */
  __pyx_t_9 = PyObject_GetAttr(__pyx_v_all_pvalues, __pyx_n_s__sort); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":3300
 *     all_pvalues.sort()
 * 
 *     for x from 0 <= x < nresults:             # <<<<<<<<<<<<<<
 * 
 *         E.debug( "progress: %i/%i " % (x+1, nresults))
 */
  __pyx_t_3 = __pyx_v_nresults;
  for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {

    /* "GatEngine.pyx":3302
 *     for x from 0 <= x < nresults:
 * 
 *         E.debug( "progress: %i/%i " % (x+1, nresults))             # <<<<<<<<<<<<<<
 *         r1 = allstats[x]
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__E); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyInt_FromLong((__pyx_v_x + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_nresults); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_102), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "GatEngine.pyx":3303
 * 
 *         E.debug( "progress: %i/%i " % (x+1, nresults))
 *         r1 = allstats[x]             # <<<<<<<<<<<<<<
 * 
 *         pvalue = r1.pvalue
 */
    __pyx_v_r1 = (__pyx_v_allstats[__pyx_v_x]);

    /* "GatEngine.pyx":3305
 *         r1 = allstats[x]
 * 
 *         pvalue = r1.pvalue             # <<<<<<<<<<<<<<
 * 
 *         if pvalue in fdr_cache:
 */
    __pyx_t_10 = __pyx_v_r1->pvalue;
    __pyx_v_pvalue = __pyx_t_10;

    /* "GatEngine.pyx":3307
 *         pvalue = r1.pvalue
 * 
 *         if pvalue in fdr_cache:             # <<<<<<<<<<<<<<
 *             r1.qvalue = fdr_cache[ pvalue ]
 *             continue
 */
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_pvalue); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = (__Pyx_PyDict_Contains(__pyx_t_6, ((PyObject *)__pyx_v_fdr_cache), Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_11) {

      /* "GatEngine.pyx":3308
 * 
 *         if pvalue in fdr_cache:
 *             r1.qvalue = fdr_cache[ pvalue ]             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
      __pyx_t_6 = PyFloat_FromDouble(__pyx_v_pvalue); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_fdr_cache), __pyx_t_6); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_r1->qvalue = __pyx_t_10;

      /* "GatEngine.pyx":3309
 *         if pvalue in fdr_cache:
 *             r1.qvalue = fdr_cache[ pvalue ]
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         efp = computeFalsePositiveRate( allstats,
 */
      goto __pyx_L7_continue;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "GatEngine.pyx":3314
 *                                         nresults,
 *                                         r1.nsamples,
 *                                         pvalue )             # <<<<<<<<<<<<<<
 * 
 *         # number of positives at P-Value
 */
    __pyx_v_efp = __pyx_f_9GatEngine_computeFalsePositiveRate(__pyx_v_allstats, __pyx_v_nresults, __pyx_v_r1->nsamples, __pyx_v_pvalue);

    /* "GatEngine.pyx":3317
 * 
 *         # number of positives at P-Value
 *         R = numpy.searchsorted( all_pvalues, r1.pvalue )             # <<<<<<<<<<<<<<
 *         while R < nresults and all_pvalues[R] <= pvalue:
 *             R += 1
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__searchsorted); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_r1->pvalue); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_all_pvalues);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_all_pvalues);
    __Pyx_GIVEREF(__pyx_v_all_pvalues);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __pyx_t_12 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_5); if (unlikely((__pyx_t_12 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_R = __pyx_t_12;

    /* "GatEngine.pyx":3318
 *         # number of positives at P-Value
 *         R = numpy.searchsorted( all_pvalues, r1.pvalue )
 *         while R < nresults and all_pvalues[R] <= pvalue:             # <<<<<<<<<<<<<<
 *             R += 1
 * 
 */
    while (1) {
      __pyx_t_11 = (__pyx_v_R < __pyx_v_nresults);
      if (__pyx_t_11) {
        __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_all_pvalues, __pyx_v_R, sizeof(__pyx_t_14GatSegmentList_Position)+1, PyLong_FromUnsignedLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_9 = PyFloat_FromDouble(__pyx_v_pvalue); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_t_9, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_14 = __pyx_t_13;
      } else {
        __pyx_t_14 = __pyx_t_11;
      }
      if (!__pyx_t_14) break;

      /* "GatEngine.pyx":3319
 *         R = numpy.searchsorted( all_pvalues, r1.pvalue )
 *         while R < nresults and all_pvalues[R] <= pvalue:
 *             R += 1             # <<<<<<<<<<<<<<
 * 
 *         r1.qvalue = dmin( 1.0, dmax( 1.0 / r1.nsamples, efp / R))
 */
      __pyx_v_R = (__pyx_v_R + 1);
    }

    /* "GatEngine.pyx":3321
 *             R += 1
 * 
 *         r1.qvalue = dmin( 1.0, dmax( 1.0 / r1.nsamples, efp / R))             # <<<<<<<<<<<<<<
 *         # print "pvalue=", r1.pvalue, "qvalue=", r1.qvalue, "efp=", efp, "nfp=", total_nfp, "nsamples=", \
 *             # r1.nsamples, "R=", R, "vals=", all_pvalues[max(0,R-3):R+3]
 */
    if (unlikely(__pyx_v_r1->nsamples == 0)) {
      PyErr_Format(PyExc_ZeroDivisionError, "float division");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (unlikely(__pyx_v_R == 0)) {
      PyErr_Format(PyExc_ZeroDivisionError, "float division");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_r1->qvalue = __pyx_f_9GatEngine_dmin(1.0, __pyx_f_9GatEngine_dmax((1.0 / __pyx_v_r1->nsamples), (__pyx_v_efp / __pyx_v_R)));

    /* "GatEngine.pyx":3325
 *             # r1.nsamples, "R=", R, "vals=", all_pvalues[max(0,R-3):R+3]
 * 
 *         fdr_cache[pvalue] = r1.qvalue             # <<<<<<<<<<<<<<
 * 
 *         break
 */
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_r1->qvalue); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyFloat_FromDouble(__pyx_v_pvalue); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(((PyObject *)__pyx_v_fdr_cache), __pyx_t_9, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "GatEngine.pyx":3327
 *         fdr_cache[pvalue] = r1.qvalue
 * 
 *         break             # <<<<<<<<<<<<<<
 * 
 * @cython.profile(False)
 */
    goto __pyx_L8_break;
    __pyx_L7_continue:;
  }
  __pyx_L8_break:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("GatEngine.computeFDR", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fdr_cache);
  __Pyx_XDECREF((PyObject *)__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_all_pvalues);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9GatEngine_41computeFDR(PyObject *__pyx_self, PyObject *__pyx_v_annotator_results); /*proto*/
static char __pyx_doc_9GatEngine_40computeFDR[] = "computeFDR(annotator_results)\ncompute an experimental fdr across all segments and annotations.\n\n    The experimental fdr is given by\n\n    E(FP) = average number of terms in each sample run with P-Value <= p\n        aka: experimental number of false positives\n\n    R = number of nodes in observed data, that have a P-Value of less than or \n        equal to p.\n        aka: pos=positives in observed data\n\n    fdr = E(FP)/R\n\n    The results are added to annotator_results.\n    ";
static PyObject *__pyx_pw_9GatEngine_41computeFDR(PyObject *__pyx_self, PyObject *__pyx_v_annotator_results) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("computeFDR (wrapper)", 0);
  __pyx_r = __pyx_pf_9GatEngine_40computeFDR(__pyx_self, ((PyObject *)__pyx_v_annotator_results));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3261
 *     return efp
 * 
 * cpdef computeFDR( annotator_results ):             # <<<<<<<<<<<<<<
 *     '''compute an experimental fdr across all segments and annotations.
 * 
 */

static PyObject *__pyx_pf_9GatEngine_40computeFDR(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_annotator_results) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("computeFDR", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9GatEngine_computeFDR(__pyx_v_annotator_results, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("GatEngine.computeFDR", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "GatEngine.pyx":3330
 * 
 * @cython.profile(False)
 * cdef inline int isSampleSignificantAtPvalue( EnrichmentStatistics * stats,             # <<<<<<<<<<<<<<
 *                                              Position sample_id,
 *                                              double pvalue ):
 */

static CYTHON_INLINE int __pyx_f_9GatEngine_isSampleSignificantAtPvalue(__pyx_t_9GatEngine_EnrichmentStatistics *__pyx_v_stats, __pyx_t_14GatSegmentList_Position __pyx_v_sample_id, double __pyx_v_pvalue) {
  double __pyx_v_pval;
  double __pyx_v_min_pval;
  double __pyx_v_val;
  __pyx_t_14GatSegmentList_Position __pyx_v_l;
  int __pyx_v_idx;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_14GatSegmentList_Position __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("isSampleSignificantAtPvalue", 0);

  /* "GatEngine.pyx":3346
 *     cdef Position l
 * 
 *     l = stats.nsamples             # <<<<<<<<<<<<<<
 *     min_pval = 1.0 / l
 * 
 */
  __pyx_t_1 = __pyx_v_stats->nsamples;
  __pyx_v_l = __pyx_t_1;

  /* "GatEngine.pyx":3347
 * 
 *     l = stats.nsamples
 *     min_pval = 1.0 / l             # <<<<<<<<<<<<<<
 * 
 *     cdef int idx
 */
  if (unlikely(__pyx_v_l == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_min_pval = (1.0 / __pyx_v_l);

  /* "GatEngine.pyx":3350
 * 
 *     cdef int idx
 *     idx = stats.sample2sorted[sample_id]             # <<<<<<<<<<<<<<
 *     val = stats.samples[sample_id]
 *     if val > stats.expected:
 */
  __pyx_v_idx = (__pyx_v_stats->sample2sorted[__pyx_v_sample_id]);

  /* "GatEngine.pyx":3351
 *     cdef int idx
 *     idx = stats.sample2sorted[sample_id]
 *     val = stats.samples[sample_id]             # <<<<<<<<<<<<<<
 *     if val > stats.expected:
 *         # over-representation
 */
  __pyx_v_val = (__pyx_v_stats->samples[__pyx_v_sample_id]);

  /* "GatEngine.pyx":3352
 *     idx = stats.sample2sorted[sample_id]
 *     val = stats.samples[sample_id]
 *     if val > stats.expected:             # <<<<<<<<<<<<<<
 *         # over-representation
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val:
 */
  __pyx_t_2 = (__pyx_v_val > __pyx_v_stats->expected);
  if (__pyx_t_2) {

    /* "GatEngine.pyx":3354
 *     if val > stats.expected:
 *         # over-representation
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val:             # <<<<<<<<<<<<<<
 *             idx -= 1
 *         idx = l - (idx + 1)
 */
    while (1) {
      __pyx_t_2 = (__pyx_v_idx > 0);
      if (__pyx_t_2) {
        __pyx_t_3 = ((__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_idx])]) == __pyx_v_val);
        __pyx_t_4 = __pyx_t_3;
      } else {
        __pyx_t_4 = __pyx_t_2;
      }
      if (!__pyx_t_4) break;

      /* "GatEngine.pyx":3355
 *         # over-representation
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val:
 *             idx -= 1             # <<<<<<<<<<<<<<
 *         idx = l - (idx + 1)
 *     elif val < stats.expected:
 */
      __pyx_v_idx = (__pyx_v_idx - 1);
    }

    /* "GatEngine.pyx":3356
 *         while idx > 0 and stats.samples[stats.sorted2sample[idx]] == val:
 *             idx -= 1
 *         idx = l - (idx + 1)             # <<<<<<<<<<<<<<
 *     elif val < stats.expected:
 *         # under-representation
 */
    __pyx_v_idx = (__pyx_v_l - (__pyx_v_idx + 1));
    goto __pyx_L3;
  }

  /* "GatEngine.pyx":3357
 *             idx -= 1
 *         idx = l - (idx + 1)
 *     elif val < stats.expected:             # <<<<<<<<<<<<<<
 *         # under-representation
 *         while idx < l and stats.samples[stats.sorted2sample[idx]] == val:
 */
  __pyx_t_4 = (__pyx_v_val < __pyx_v_stats->expected);
  if (__pyx_t_4) {

    /* "GatEngine.pyx":3359
 *     elif val < stats.expected:
 *         # under-representation
 *         while idx < l and stats.samples[stats.sorted2sample[idx]] == val:             # <<<<<<<<<<<<<<
 *             idx += 1
 * 
 */
    while (1) {
      __pyx_t_4 = (__pyx_v_idx < __pyx_v_l);
      if (__pyx_t_4) {
        __pyx_t_2 = ((__pyx_v_stats->samples[(__pyx_v_stats->sorted2sample[__pyx_v_idx])]) == __pyx_v_val);
        __pyx_t_3 = __pyx_t_2;
      } else {
        __pyx_t_3 = __pyx_t_4;
      }
      if (!__pyx_t_3) break;

      /* "GatEngine.pyx":3360
 *         # under-representation
 *         while idx < l and stats.samples[stats.sorted2sample[idx]] == val:
 *             idx += 1             # <<<<<<<<<<<<<<
 * 
 *     pval = float(idx) / l
 */
      __pyx_v_idx = (__pyx_v_idx + 1);
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "GatEngine.pyx":3362
 *             idx += 1
 * 
 *     pval = float(idx) / l             # <<<<<<<<<<<<<<
 * 
 *     # = is important, such that a sample itself is called significant
 */
  if (unlikely(__pyx_v_l == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_pval = (((double)__pyx_v_idx) / __pyx_v_l);

  /* "GatEngine.pyx":3366
 *     # = is important, such that a sample itself is called significant
 *     # print "val=", val, "idx=", idx, "sample_id=", sample_id, "pval=", pval, "refpval=", pvalue, "true=", pval <= pvalue
 *     return dmax( min_pval, pval ) <= pvalue             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_f_9GatEngine_dmax(__pyx_v_min_pval, __pyx_v_pval) <= __pyx_v_pvalue);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("GatEngine.isSampleSignificantAtPvalue", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":194
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_v_hasfields;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  char *__pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "numpy.pxd":200
 *             # of flags
 * 
 *             if info == NULL: return             # <<<<<<<<<<<<<<
 * 
 *             cdef int copy_shape, i, ndim
 */
  __pyx_t_1 = (__pyx_v_info == NULL);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "numpy.pxd":203
 * 
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "numpy.pxd":204
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "numpy.pxd":206
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);

  /* "numpy.pxd":208
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
  if (__pyx_t_1) {

    /* "numpy.pxd":209
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "numpy.pxd":211
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
    __pyx_v_copy_shape = 0;
  }
  __pyx_L4:;

  /* "numpy.pxd":213
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
  if (__pyx_t_1) {

    /* "numpy.pxd":214
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
    __pyx_t_2 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS));
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "numpy.pxd":215
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_104), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "numpy.pxd":217
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
  if (__pyx_t_3) {

    /* "numpy.pxd":218
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
    __pyx_t_1 = (!PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS));
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "numpy.pxd":219
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_106), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "numpy.pxd":221
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);

  /* "numpy.pxd":222
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info.
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "numpy.pxd":223
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
  if (__pyx_v_copy_shape) {

    /* "numpy.pxd":226
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));

    /* "numpy.pxd":227
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "numpy.pxd":228
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_5 = __pyx_v_ndim;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "numpy.pxd":229
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);

      /* "numpy.pxd":230
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
    }
    goto __pyx_L7;
  }
  /*else*/ {

    /* "numpy.pxd":232
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "numpy.pxd":233
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  }
  __pyx_L7:;

  /* "numpy.pxd":234
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "numpy.pxd":235
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);

  /* "numpy.pxd":236
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(__pyx_v_self));

  /* "numpy.pxd":239
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef list stack
 */
  __pyx_v_f = NULL;

  /* "numpy.pxd":240
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef list stack
 *             cdef int offset
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->descr);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "numpy.pxd":244
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "numpy.pxd":246
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_t_2 = (!__pyx_v_hasfields);
  if (__pyx_t_2) {
    __pyx_t_3 = (!__pyx_v_copy_shape);
    __pyx_t_1 = __pyx_t_3;
  } else {
    __pyx_t_1 = __pyx_t_2;
  }
  if (__pyx_t_1) {

    /* "numpy.pxd":248
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "numpy.pxd":251
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  }
  __pyx_L10:;

  /* "numpy.pxd":253
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  __pyx_t_1 = (!__pyx_v_hasfields);
  if (__pyx_t_1) {

    /* "numpy.pxd":254
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 */
    __pyx_t_5 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_5;

    /* "numpy.pxd":255
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_1 = (__pyx_v_descr->byteorder == '>');
    if (__pyx_t_1) {
      __pyx_t_2 = __pyx_v_little_endian;
    } else {
      __pyx_t_2 = __pyx_t_1;
    }
    if (!__pyx_t_2) {

      /* "numpy.pxd":256
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
      __pyx_t_1 = (__pyx_v_descr->byteorder == '<');
      if (__pyx_t_1) {
        __pyx_t_3 = (!__pyx_v_little_endian);
        __pyx_t_7 = __pyx_t_3;
      } else {
        __pyx_t_7 = __pyx_t_1;
      }
      __pyx_t_1 = __pyx_t_7;
    } else {
      __pyx_t_1 = __pyx_t_2;
    }
    if (__pyx_t_1) {

      /* "numpy.pxd":257
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_108), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "numpy.pxd":258
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_BYTE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__b;
      goto __pyx_L13;
    }

    /* "numpy.pxd":259
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_UBYTE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__B;
      goto __pyx_L13;
    }

    /* "numpy.pxd":260
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_SHORT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__h;
      goto __pyx_L13;
    }

    /* "numpy.pxd":261
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_USHORT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__H;
      goto __pyx_L13;
    }

    /* "numpy.pxd":262
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_INT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__i;
      goto __pyx_L13;
    }

    /* "numpy.pxd":263
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_UINT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__I;
      goto __pyx_L13;
    }

    /* "numpy.pxd":264
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_LONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__l;
      goto __pyx_L13;
    }

    /* "numpy.pxd":265
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_ULONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__L;
      goto __pyx_L13;
    }

    /* "numpy.pxd":266
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__q;
      goto __pyx_L13;
    }

    /* "numpy.pxd":267
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Q;
      goto __pyx_L13;
    }

    /* "numpy.pxd":268
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_FLOAT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__f;
      goto __pyx_L13;
    }

    /* "numpy.pxd":269
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__d;
      goto __pyx_L13;
    }

    /* "numpy.pxd":270
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__g;
      goto __pyx_L13;
    }

    /* "numpy.pxd":271
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Zf;
      goto __pyx_L13;
    }

    /* "numpy.pxd":272
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Zd;
      goto __pyx_L13;
    }

    /* "numpy.pxd":273
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
    __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Zg;
      goto __pyx_L13;
    }

    /* "numpy.pxd":274
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
    __pyx_t_1 = (__pyx_v_t == NPY_OBJECT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__O;
      goto __pyx_L13;
    }
    /*else*/ {

      /* "numpy.pxd":276
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_4 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_109), __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L13:;

    /* "numpy.pxd":277
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "numpy.pxd":278
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "numpy.pxd":280
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 */
    __pyx_v_info->format = ((char *)malloc(255));

    /* "numpy.pxd":281
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "numpy.pxd":282
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "numpy.pxd":285
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)             # <<<<<<<<<<<<<<
 *                 f[0] = c'\0' # Terminate format string
 * 
 */
    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_f = __pyx_t_9;

    /* "numpy.pxd":286
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = c'\0' # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = '\x00';
  }
  __pyx_L11:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
  __Pyx_RefNannyFinishContext();
}

/* "numpy.pxd":288
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "numpy.pxd":289
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = PyArray_HASFIELDS(__pyx_v_self);
  if (__pyx_t_1) {

    /* "numpy.pxd":290
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "numpy.pxd":291
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
  if (__pyx_t_1) {

    /* "numpy.pxd":292
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);
    goto __pyx_L4;
  }
  __pyx_L4:;

  __Pyx_RefNannyFinishContext();
}

/* "numpy.pxd":768
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);

  /* "numpy.pxd":769
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":771
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);

  /* "numpy.pxd":772
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":774
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);

  /* "numpy.pxd":775
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":777
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);

  /* "numpy.pxd":778
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":780
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);

  /* "numpy.pxd":781
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":783
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child = 0;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_childname = NULL;
  PyObject *__pyx_v_new_offset = NULL;
  PyObject *__pyx_v_t = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  char *__pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);

  /* "numpy.pxd":790
 *     cdef int delta_offset
 *     cdef tuple i
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "numpy.pxd":791
 *     cdef tuple i
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "numpy.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(((PyObject *)__pyx_v_descr->names) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF(__pyx_v_childname);
    __pyx_v_childname = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "numpy.pxd":795
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_fields));
    __pyx_v_fields = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "numpy.pxd":796
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 */
    if (likely(PyTuple_CheckExact(((PyObject *)__pyx_v_fields)))) {
      PyObject* sequence = ((PyObject *)__pyx_v_fields);
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (1) {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_fields)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_child));
    __pyx_v_child = ((PyArray_Descr *)__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_v_new_offset);
    __pyx_v_new_offset = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "numpy.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_7) {

      /* "numpy.pxd":799
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
      __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_111), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "numpy.pxd":801
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_7 = (__pyx_v_child->byteorder == '>');
    if (__pyx_t_7) {
      __pyx_t_8 = __pyx_v_little_endian;
    } else {
      __pyx_t_8 = __pyx_t_7;
    }
    if (!__pyx_t_8) {

      /* "numpy.pxd":802
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
      __pyx_t_7 = (__pyx_v_child->byteorder == '<');
      if (__pyx_t_7) {
        __pyx_t_9 = (!__pyx_v_little_endian);
        __pyx_t_10 = __pyx_t_9;
      } else {
        __pyx_t_10 = __pyx_t_7;
      }
      __pyx_t_7 = __pyx_t_10;
    } else {
      __pyx_t_7 = __pyx_t_8;
    }
    if (__pyx_t_7) {

      /* "numpy.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_112), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "numpy.pxd":813
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!__pyx_t_7) break;

      /* "numpy.pxd":814
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 120;

      /* "numpy.pxd":815
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "numpy.pxd":816
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_11 = 0;
      (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + 1);
    }

    /* "numpy.pxd":818
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_11 = 0;
    (__pyx_v_offset[__pyx_t_11]) = ((__pyx_v_offset[__pyx_t_11]) + __pyx_v_child->elsize);

    /* "numpy.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_7 = (!PyDataType_HASFIELDS(__pyx_v_child));
    if (__pyx_t_7) {

      /* "numpy.pxd":821
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_v_t);
      __pyx_v_t = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "numpy.pxd":822
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_7 = ((__pyx_v_end - __pyx_v_f) < 5);
      if (__pyx_t_7) {

        /* "numpy.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_114), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "numpy.pxd":826
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L13;
      }

      /* "numpy.pxd":827
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L13;
      }

      /* "numpy.pxd":828
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 104;
        goto __pyx_L13;
      }

      /* "numpy.pxd":829
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L13;
      }

      /* "numpy.pxd":830
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 105;
        goto __pyx_L13;
      }

      /* "numpy.pxd":831
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L13;
      }

      /* "numpy.pxd":832
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 108;
        goto __pyx_L13;
      }

      /* "numpy.pxd":833
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L13;
      }

      /* "numpy.pxd":834
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 113;
        goto __pyx_L13;
      }

      /* "numpy.pxd":835
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L13;
      }

      /* "numpy.pxd":836
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 102;
        goto __pyx_L13;
      }

      /* "numpy.pxd":837
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_5 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 100;
        goto __pyx_L13;
      }

      /* "numpy.pxd":838
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_3 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 103;
        goto __pyx_L13;
      }

      /* "numpy.pxd":839
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_5 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 102;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L13;
      }

      /* "numpy.pxd":840
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 100;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L13;
      }

      /* "numpy.pxd":841
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_5 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 103;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L13;
      }

      /* "numpy.pxd":842
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_3 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_7) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L13;
      }
      /*else*/ {

        /* "numpy.pxd":844
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_109), __pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
        __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L13:;

      /* "numpy.pxd":845
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f = (__pyx_v_f + 1);
      goto __pyx_L11;
    }
    /*else*/ {

      /* "numpy.pxd":849
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
      __pyx_t_12 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_f = __pyx_t_12;
    }
    __pyx_L11:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "numpy.pxd":850
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_v_childname);
  __Pyx_XDECREF(__pyx_v_new_offset);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "numpy.pxd":965
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  PyObject *__pyx_v_baseptr;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "numpy.pxd":967
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
  __pyx_t_1 = (__pyx_v_base == Py_None);
  if (__pyx_t_1) {

    /* "numpy.pxd":968
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "numpy.pxd":970
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
    Py_INCREF(__pyx_v_base);

    /* "numpy.pxd":971
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr
 */
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  }
  __pyx_L3:;

  /* "numpy.pxd":972
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 *      arr.base = baseptr
 * 
 */
  Py_XDECREF(__pyx_v_arr->base);

  /* "numpy.pxd":973
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  __pyx_v_arr->base = __pyx_v_baseptr;

  __Pyx_RefNannyFinishContext();
}

/* "numpy.pxd":975
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base", 0);

  /* "numpy.pxd":976
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = (__pyx_v_arr->base == NULL);
  if (__pyx_t_1) {

    /* "numpy.pxd":977
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>arr.base
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "numpy.pxd":979
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_tp_new_9GatEngine_IntervalContainer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_IntervalContainer *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_IntervalContainer *)o);
  p->shared_fn = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->intervals = Py_None; Py_INCREF(Py_None);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_IntervalContainer(PyObject *o) {
  struct __pyx_obj_9GatEngine_IntervalContainer *p = (struct __pyx_obj_9GatEngine_IntervalContainer *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_17IntervalContainer_11__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->shared_fn);
  Py_CLEAR(p->intervals);
  Py_CLEAR(p->name);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_IntervalContainer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_IntervalContainer *p = (struct __pyx_obj_9GatEngine_IntervalContainer *)o;
  if (p->shared_fn) {
    e = (*v)(p->shared_fn, a); if (e) return e;
  }
  if (p->intervals) {
    e = (*v)(p->intervals, a); if (e) return e;
  }
  if (p->name) {
    e = (*v)(p->name, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_IntervalContainer(PyObject *o) {
  struct __pyx_obj_9GatEngine_IntervalContainer *p = (struct __pyx_obj_9GatEngine_IntervalContainer *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->shared_fn);
  p->shared_fn = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->intervals);
  p->intervals = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->name);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine_IntervalContainer[] = {
  {__Pyx_NAMESTR("getName"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_3getName, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_2getName)},
  {__Pyx_NAMESTR("setName"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_5setName, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_4setName)},
  {__Pyx_NAMESTR("_getSharedMemoryName"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_7_getSharedMemoryName, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_6_getSharedMemoryName)},
  {__Pyx_NAMESTR("share"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_9share, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_8share)},
  {__Pyx_NAMESTR("unshare"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_13unshare, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_12unshare)},
  {__Pyx_NAMESTR("sum"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_15sum, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_14sum)},
  {__Pyx_NAMESTR("counts"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_17counts, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_16counts)},
  {__Pyx_NAMESTR("sort"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_19sort, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_18sort)},
  {__Pyx_NAMESTR("extend"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_21extend, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_20extend)},
  {__Pyx_NAMESTR("expand"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_23expand, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_22expand)},
  {__Pyx_NAMESTR("normalize"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_25normalize, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_24normalize)},
  {__Pyx_NAMESTR("check"), (PyCFunction)__pyx_pw_9GatEngine_17IntervalContainer_27check, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17IntervalContainer_26check)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_IntervalContainer = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_IntervalContainer = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_IntervalContainer = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_IntervalContainer = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_IntervalContainer = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.IntervalContainer"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_IntervalContainer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_IntervalContainer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_IntervalContainer, /*tp_as_number*/
  &__pyx_tp_as_sequence_IntervalContainer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_IntervalContainer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_IntervalContainer, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("IntervalContainer()\ngeneric container class representing a collection of SegmentList objects.\n    \n    The base class implements sending/retrieving data to/from shared memory.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_IntervalContainer, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_IntervalContainer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_IntervalContainer, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_17IntervalContainer_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_IntervalContainer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_IntervalDictionary(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_IntervalContainer(t, a, k);
  if (!o) return 0;
  return o;
}
static PyObject *__pyx_sq_item_9GatEngine_IntervalDictionary(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_9GatEngine_IntervalDictionary(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_9GatEngine_18IntervalDictionary_26__setitem__(o, i, v);
  }
  else {
    return __pyx_pw_9GatEngine_18IntervalDictionary_16__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_9GatEngine_IntervalDictionary[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_2__reduce__)},
  {__Pyx_NAMESTR("getSegmentLists"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_5getSegmentLists, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_4getSegmentLists)},
  {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_8intersect, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_7intersect)},
  {__Pyx_NAMESTR("truncate"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_10truncate, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_9truncate)},
  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_18keys, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_17keys)},
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_20add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_19add)},
  {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_22items, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_21items)},
  {__Pyx_NAMESTR("iteritems"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_30iteritems, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_29iteritems)},
  {__Pyx_NAMESTR("clone"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_32clone, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_31clone)},
  {__Pyx_NAMESTR("filter"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_34filter, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_33filter)},
  {__Pyx_NAMESTR("toIsochores"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_36toIsochores, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_35toIsochores)},
  {__Pyx_NAMESTR("fromIsochores"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalDictionary_38fromIsochores, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalDictionary_37fromIsochores)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_IntervalDictionary = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_IntervalDictionary = {
  __pyx_pw_9GatEngine_18IntervalDictionary_12__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_9GatEngine_IntervalDictionary, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_9GatEngine_18IntervalDictionary_28__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_IntervalDictionary = {
  __pyx_pw_9GatEngine_18IntervalDictionary_12__len__, /*mp_length*/
  __pyx_pw_9GatEngine_18IntervalDictionary_24__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_9GatEngine_IntervalDictionary, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_IntervalDictionary = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_IntervalDictionary = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.IntervalDictionary"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_IntervalDictionary), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_IntervalContainer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_IntervalDictionary, /*tp_as_number*/
  &__pyx_tp_as_sequence_IntervalDictionary, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_IntervalDictionary, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9GatEngine_18IntervalDictionary_14__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_IntervalDictionary, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("IntervalDictionary(name=None, unreduce=None)\na collection of intervals.\n    \n    Intervals (objects of type :class:`SegmentList`) are organized\n    in hierarchical dictionary by isochore.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_IntervalContainer, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_IntervalContainer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_IntervalDictionary, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_18IntervalDictionary_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_IntervalDictionary, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_IntervalCollection(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_IntervalContainer(t, a, k);
  if (!o) return 0;
  return o;
}
static PyObject *__pyx_sq_item_9GatEngine_IntervalCollection(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_9GatEngine_IntervalCollection(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    if (__pyx_ptype_9GatEngine_IntervalContainer->tp_as_mapping && __pyx_ptype_9GatEngine_IntervalContainer->tp_as_mapping->mp_ass_subscript)
      return __pyx_ptype_9GatEngine_IntervalContainer->tp_as_mapping->mp_ass_subscript(o, i, v);
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript assignment not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
  else {
    return __pyx_pw_9GatEngine_18IntervalCollection_38__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_9GatEngine_IntervalCollection[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_2__reduce__)},
  {__Pyx_NAMESTR("getSegmentLists"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_5getSegmentLists, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_4getSegmentLists)},
  {__Pyx_NAMESTR("load"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_8load, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_7load)},
  {__Pyx_NAMESTR("save"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_10save, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_9save)},
  {__Pyx_NAMESTR("normalize"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_12normalize, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_11normalize)},
  {__Pyx_NAMESTR("outputStats"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_14outputStats, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_13outputStats)},
  {__Pyx_NAMESTR("merge"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_16merge, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_15merge)},
  {__Pyx_NAMESTR("collapse"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_18collapse, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_17collapse)},
  {__Pyx_NAMESTR("countsPerTrack"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_20countsPerTrack, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_19countsPerTrack)},
  {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_22intersect, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_21intersect)},
  {__Pyx_NAMESTR("filter"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_24filter, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_23filter)},
  {__Pyx_NAMESTR("restrict"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_26restrict, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_25restrict)},
  {__Pyx_NAMESTR("toIsochores"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_28toIsochores, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_27toIsochores)},
  {__Pyx_NAMESTR("fromIsochores"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_30fromIsochores, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_29fromIsochores)},
  {__Pyx_NAMESTR("clone"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_32clone, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_31clone)},
  {__Pyx_NAMESTR("tracks"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_34tracks, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_33tracks)},
  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_40keys, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_39keys)},
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_42add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_41add)},
  {__Pyx_NAMESTR("iteritems"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_50iteritems, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_49iteritems)},
  {__Pyx_NAMESTR("outputOverlapStats"), (PyCFunction)__pyx_pw_9GatEngine_18IntervalCollection_52outputOverlapStats, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18IntervalCollection_51outputOverlapStats)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_IntervalCollection = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_IntervalCollection = {
  __pyx_pw_9GatEngine_18IntervalCollection_36__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_9GatEngine_IntervalCollection, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_9GatEngine_18IntervalCollection_46__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_IntervalCollection = {
  __pyx_pw_9GatEngine_18IntervalCollection_36__len__, /*mp_length*/
  __pyx_pw_9GatEngine_18IntervalCollection_44__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_9GatEngine_IntervalCollection, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_IntervalCollection = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_IntervalCollection = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.IntervalCollection"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_IntervalCollection), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_IntervalContainer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_IntervalCollection, /*tp_as_number*/
  &__pyx_tp_as_sequence_IntervalCollection, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_IntervalCollection, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9GatEngine_18IntervalCollection_48__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_IntervalCollection, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("IntervalCollection(name=None, unreduce=None)\na collection of intervals.\n\n    Intervals (objects of type :class:`SegmentList`) are organized\n    in hierarchical dictionary first by track and then by isochore.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_IntervalContainer, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_IntervalContainer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_IntervalCollection, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_18IntervalCollection_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_IntervalCollection, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerSlow __pyx_vtable_9GatEngine_SegmentListSamplerSlow;

static PyObject *__pyx_tp_new_9GatEngine_SegmentListSamplerSlow(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SegmentListSamplerSlow;
  p->segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); Py_INCREF(Py_None);
  p->cdf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_SegmentListSamplerSlow(PyObject *o) {
  struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *p = (struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->segment_list);
  Py_CLEAR(p->cdf);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_SegmentListSamplerSlow(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *p = (struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *)o;
  if (p->segment_list) {
    e = (*v)(((PyObject*)p->segment_list), a); if (e) return e;
  }
  if (p->cdf) {
    e = (*v)(((PyObject*)p->cdf), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_SegmentListSamplerSlow(PyObject *o) {
  struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *p = (struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->segment_list);
  p->segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->cdf);
  p->cdf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine_SegmentListSamplerSlow[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_22SegmentListSamplerSlow_3sample, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_22SegmentListSamplerSlow_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SegmentListSamplerSlow = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SegmentListSamplerSlow = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SegmentListSamplerSlow = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SegmentListSamplerSlow = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SegmentListSamplerSlow = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SegmentListSamplerSlow"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_SegmentListSamplerSlow, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SegmentListSamplerSlow, /*tp_as_number*/
  &__pyx_tp_as_sequence_SegmentListSamplerSlow, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SegmentListSamplerSlow, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SegmentListSamplerSlow, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("SegmentListSamplerSlow(SegmentList segment_list)"), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_SegmentListSamplerSlow, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_SegmentListSamplerSlow, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SegmentListSamplerSlow, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_22SegmentListSamplerSlow_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SegmentListSamplerSlow, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SegmentListSamplerWithEdgeEffects __pyx_vtable_9GatEngine_SegmentListSamplerWithEdgeEffects;

static PyObject *__pyx_tp_new_9GatEngine_SegmentListSamplerWithEdgeEffects(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SegmentListSamplerWithEdgeEffects;
  p->segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_SegmentListSamplerWithEdgeEffects(PyObject *o) {
  struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *p = (struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->segment_list);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_SegmentListSamplerWithEdgeEffects(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *p = (struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)o;
  if (p->segment_list) {
    e = (*v)(((PyObject*)p->segment_list), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_SegmentListSamplerWithEdgeEffects(PyObject *o) {
  struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *p = (struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->segment_list);
  p->segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine_SegmentListSamplerWithEdgeEffects[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_3sample, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_33SegmentListSamplerWithEdgeEffects_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SegmentListSamplerWithEdgeEffects = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SegmentListSamplerWithEdgeEffects = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SegmentListSamplerWithEdgeEffects = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SegmentListSamplerWithEdgeEffects = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SegmentListSamplerWithEdgeEffects = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SegmentListSamplerWithEdgeEffects"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_SegmentListSamplerWithEdgeEffects, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SegmentListSamplerWithEdgeEffects, /*tp_as_number*/
  &__pyx_tp_as_sequence_SegmentListSamplerWithEdgeEffects, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SegmentListSamplerWithEdgeEffects, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SegmentListSamplerWithEdgeEffects, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("SegmentListSamplerWithEdgeEffects(SegmentList segment_list)"), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_SegmentListSamplerWithEdgeEffects, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_SegmentListSamplerWithEdgeEffects, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SegmentListSamplerWithEdgeEffects, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_33SegmentListSamplerWithEdgeEffects_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SegmentListSamplerWithEdgeEffects, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SegmentListSampler __pyx_vtable_9GatEngine_SegmentListSampler;

static PyObject *__pyx_tp_new_9GatEngine_SegmentListSampler(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_SegmentListSampler *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SegmentListSampler *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SegmentListSampler;
  p->segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_SegmentListSampler(PyObject *o) {
  struct __pyx_obj_9GatEngine_SegmentListSampler *p = (struct __pyx_obj_9GatEngine_SegmentListSampler *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_18SegmentListSampler_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->segment_list);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_SegmentListSampler(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_SegmentListSampler *p = (struct __pyx_obj_9GatEngine_SegmentListSampler *)o;
  if (p->segment_list) {
    e = (*v)(((PyObject*)p->segment_list), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_SegmentListSampler(PyObject *o) {
  struct __pyx_obj_9GatEngine_SegmentListSampler *p = (struct __pyx_obj_9GatEngine_SegmentListSampler *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->segment_list);
  p->segment_list = ((struct __pyx_obj_14GatSegmentList_SegmentList *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine_SegmentListSampler[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_18SegmentListSampler_3sample, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_18SegmentListSampler_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SegmentListSampler = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SegmentListSampler = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SegmentListSampler = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SegmentListSampler = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SegmentListSampler = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SegmentListSampler"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SegmentListSampler), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_SegmentListSampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SegmentListSampler, /*tp_as_number*/
  &__pyx_tp_as_sequence_SegmentListSampler, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SegmentListSampler, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SegmentListSampler, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("SegmentListSampler(SegmentList segment_list)\nreturn a new position within segment list.\n\n    The probability of overlap is proportional\n    to the workspace size.\n\n    In order to avoid edge effects the position\n    of the sample within a workspace segment is\n    sampled again.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_SegmentListSampler, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_SegmentListSampler, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SegmentListSampler, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_18SegmentListSampler_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SegmentListSampler, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_HistogramSamplerSlow __pyx_vtable_9GatEngine_HistogramSamplerSlow;

static PyObject *__pyx_tp_new_9GatEngine_HistogramSamplerSlow(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_HistogramSamplerSlow *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_HistogramSamplerSlow *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_HistogramSamplerSlow;
  p->cdf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_HistogramSamplerSlow(PyObject *o) {
  struct __pyx_obj_9GatEngine_HistogramSamplerSlow *p = (struct __pyx_obj_9GatEngine_HistogramSamplerSlow *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->cdf);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_HistogramSamplerSlow(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_HistogramSamplerSlow *p = (struct __pyx_obj_9GatEngine_HistogramSamplerSlow *)o;
  if (p->cdf) {
    e = (*v)(((PyObject*)p->cdf), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_HistogramSamplerSlow(PyObject *o) {
  struct __pyx_obj_9GatEngine_HistogramSamplerSlow *p = (struct __pyx_obj_9GatEngine_HistogramSamplerSlow *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->cdf);
  p->cdf = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine_HistogramSamplerSlow[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_20HistogramSamplerSlow_3sample, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_20HistogramSamplerSlow_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_HistogramSamplerSlow = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_HistogramSamplerSlow = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_HistogramSamplerSlow = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_HistogramSamplerSlow = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_HistogramSamplerSlow = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.HistogramSamplerSlow"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_HistogramSamplerSlow), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_HistogramSamplerSlow, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_HistogramSamplerSlow, /*tp_as_number*/
  &__pyx_tp_as_sequence_HistogramSamplerSlow, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_HistogramSamplerSlow, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_HistogramSamplerSlow, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("HistogramSamplerSlow(ndarray histogram, Position bucket_size)"), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_HistogramSamplerSlow, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_HistogramSamplerSlow, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_HistogramSamplerSlow, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_20HistogramSamplerSlow_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_HistogramSamplerSlow, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_HistogramSampler __pyx_vtable_9GatEngine_HistogramSampler;

static PyObject *__pyx_tp_new_9GatEngine_HistogramSampler(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_HistogramSampler *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_HistogramSampler *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_HistogramSampler;
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_HistogramSampler(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_16HistogramSampler_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_9GatEngine_HistogramSampler[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_16HistogramSampler_3sample, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_16HistogramSampler_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_HistogramSampler = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_HistogramSampler = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_HistogramSampler = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_HistogramSampler = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_HistogramSampler = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.HistogramSampler"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_HistogramSampler), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_HistogramSampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_HistogramSampler, /*tp_as_number*/
  &__pyx_tp_as_sequence_HistogramSampler, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_HistogramSampler, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_HistogramSampler, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("HistogramSampler(ndarray histogram, Position bucket_size)"), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_HistogramSampler, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_16HistogramSampler_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_HistogramSampler, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_Sampler(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_Sampler(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_9GatEngine_Sampler[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Sampler = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Sampler = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Sampler = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Sampler = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_Sampler = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.Sampler"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_Sampler), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Sampler, /*tp_as_number*/
  &__pyx_tp_as_sequence_Sampler, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Sampler, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Sampler, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_Sampler, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_Sampler, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerAnnotator __pyx_vtable_9GatEngine_SamplerAnnotator;

static PyObject *__pyx_tp_new_9GatEngine_SamplerAnnotator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerAnnotator *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerAnnotator *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerAnnotator;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerAnnotator[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_16SamplerAnnotator_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_16SamplerAnnotator_2__reduce__)},
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_16SamplerAnnotator_5sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_16SamplerAnnotator_4sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerAnnotator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerAnnotator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerAnnotator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerAnnotator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerAnnotator = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerAnnotator"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerAnnotator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerAnnotator, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerAnnotator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerAnnotator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerAnnotator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerAnnotator(bucket_size=1, nbuckets=100000, nunsuccessful_rounds=0)\n\n    sample with the annotator method.\n\n    Samples are created in a two step procedure. First, the length\n    of a sample segment is chosen randomly from the empirical segment\n    length distribution. Then, a random coordinate is chosen. The sampling\n    stops when exactly the same number of nucleotides in the sampled segments \n    overlap the workspace as in the input.\n\n    This method does not truncate segments to the workspace before\n    or after sampling. The truncation can happen before and/or after\n    the algorithm finishes.\n\n    The sampling algorithm avoids checking for segment overlap until\n    the number of nucleotides sampled reaches the expected count.\n    Then, overlapping and adjacent segments are merged and the actual\n    number of nucleotides overlapping the workspace computed.\n\n    In case of over-shoot, a random segment and position within the current \n    sample is chosen and the overshoot is removed by trimming in a random\n    direction.\n\n    In case of under-shoot, the sampling process continues as usual. It \n    will converge if a segment of the appropriate length is sampled and\n    placed without overlap or a sampled segment overlaps a previously\n    sampled segment and due to the merging process increments its length\n    by the correct number of bases.\n\n    Conceptually this corresponds to a random process where the probability\n    that a segment gains or loses a certain number of nucleotides is independent\n    of the size of the segment (Poisson Process). An example of segments of this\n    type are regions of conservation, indel-purified segments or inter-gap \n    segment lengths.\n\n    Note that the length distribution of the sampled segments is not exactly \n    the same as the input segments. Also, the number of segments sampled will\n    differ from the number of segments in the input set.\n\n    This method is quick if the workspace is large compared to the segments that\n    need to be placed. If it is small, a large number of samples will be rejected.\n\n    *bucket_size* - bin size for empirical length distribution\n\n    *nbuckets* - number of bins of the empirical length distribution\n\n    The product of *bucket_size* and *nbuckets* needs to be larger than\n    the largest segment in the input set.\n\n    returns a SegmentList of sampled segments.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerAnnotator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_16SamplerAnnotator_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerAnnotator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerSegments __pyx_vtable_9GatEngine_SamplerSegments;

static PyObject *__pyx_tp_new_9GatEngine_SamplerSegments(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerSegments *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerSegments *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerSegments;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerSegments[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_15SamplerSegments_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_15SamplerSegments_2__reduce__)},
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_15SamplerSegments_5sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_15SamplerSegments_4sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerSegments = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerSegments = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerSegments = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerSegments = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerSegments = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerSegments"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerSegments), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerSegments, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerSegments, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerSegments, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerSegments, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerSegments(bucket_size=1, nbuckets=100000)\n\n    sample *n* segments from segment length distribution.\n\n    Samples are created in a two step procedure. First, the length\n    of a sample segment is chosen randomly from the empirical segment\n    length distribution. Then, a random coordinate is chosen. The sampling\n    stops when exactly *n* segments have been placed.\n    \n    Sampled segments may overlap.\n\n    The segment length distribution is derived from\n    the argument *segments* supplied to the :meth:`sample`\n    method.\n\n    *n* is given by the number of segments in the observed\n    data.\n\n    *segments* does not need to be normalized. In fact,\n    supplying overlapping segments is likely to be the \n    most realistic use case.\n\n    *bucket_size* - bin size for empirical length distribution\n\n    *nbuckets* - number of bins of the empirical length distribution\n\n    The product of *bucket_size* and *nbuckets* needs to be larger than\n    the largest segment in the input set.\n\n    returns a SegmentList of sampled segments.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerSegments, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_15SamplerSegments_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerSegments, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerBruteForce __pyx_vtable_9GatEngine_SamplerBruteForce;

static PyObject *__pyx_tp_new_9GatEngine_SamplerBruteForce(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerBruteForce *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerBruteForce *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerBruteForce;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerBruteForce[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_17SamplerBruteForce_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17SamplerBruteForce_2__reduce__)},
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_17SamplerBruteForce_5sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_17SamplerBruteForce_4sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerBruteForce = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerBruteForce = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerBruteForce = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerBruteForce = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerBruteForce = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerBruteForce"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerBruteForce), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerBruteForce, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerBruteForce, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerBruteForce, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerBruteForce, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerBruteForce(bucket_size=1, nbuckets=100000, ntries_inner=100, ntries_outer=10)\n\n    sample segments from length distribution until\n    workspace is covered by at least the same number of nucleotides\n    as the input.\n\n    This sampler applies a brute force algorithm - segments \n    are added only if the do not overlap with a previously\n    sampled segment.\n\n    The segment length distribution is derived from\n    the argument *segments* supplied to the :meth:`sample`\n    method.\n\n    *bucket_size* - bin size for empirical length distribution\n\n    *nbuckets* - number of bins of the empirical length distribution\n\n    The product of *bucket_size* and *nbuckets* needs to be larger than\n    the largest segment in the input set.\n\n    returns a SegmentList of sampled segments.\n\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerBruteForce, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_17SamplerBruteForce_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerBruteForce, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerUniform __pyx_vtable_9GatEngine_SamplerUniform;

static PyObject *__pyx_tp_new_9GatEngine_SamplerUniform(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerUniform *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerUniform *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerUniform;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerUniform[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_14SamplerUniform_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_14SamplerUniform_2__reduce__)},
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_14SamplerUniform_5sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_14SamplerUniform_4sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerUniform = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerUniform = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerUniform = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerUniform = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerUniform = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerUniform"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerUniform), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerUniform, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerUniform, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerUniform, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerUniform, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerUniform(increment, bucket_size=1, nbuckets=100000, current_orientation=0, current_workspace=0, current_position=0)\n\n    For debugging purposes.\n\n    Every *increment* residues within the :term:`workspace`\n    a new segment is generated. The segment length is\n    taken from the segment size distribution of the input set.\n\n    Sampled segments extend from the position selected alternately into \n    into forward or reverse direction.\n\n    *bucket_size* - bin size for empirical length distribution\n\n    *nbuckets* - number of bins of the empirical length distribution\n\n    The product of *bucket_size* and *nbuckets* needs to be larger than\n    the largest segment in the input set.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerUniform, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_14SamplerUniform_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerUniform, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerShift __pyx_vtable_9GatEngine_SamplerShift;

static PyObject *__pyx_tp_new_9GatEngine_SamplerShift(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerShift *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerShift *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerShift;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerShift[] = {
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_9GatEngine_12SamplerShift_3__reduce__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12SamplerShift_2__reduce__)},
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_12SamplerShift_5sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12SamplerShift_4sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerShift = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerShift = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerShift = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerShift = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerShift = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerShift"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerShift), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerShift, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerShift, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerShift, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerShift, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerShift(radius=2, extension=0)\n\n    Sample segments by shifting them by a random amount within *radius*\n    in a random direction.\n\n    This sampler can be used to investigate overlap between\n    two types of genomic annotations that tend to co-occur.\n    An example are two transcription factors that tend to \n    occur in the promotor of the same genes. \n\n    *radius* determines the size of the region that is accessible \n    for randomly shifting a segment. It is expressed as a fraction \n    of the size of a segment.\n\n    In the sampling procedure, the start of the segment is shifted\n    within radius. It is then wrapped around any discontinuities in the workspace. If\n    the segment extends beyond the radius, the remaining nucleotides will\n    be wrapped around.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerShift, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_12SamplerShift_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerShift, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerLocalPermutation __pyx_vtable_9GatEngine_SamplerLocalPermutation;

static PyObject *__pyx_tp_new_9GatEngine_SamplerLocalPermutation(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerLocalPermutation *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerLocalPermutation *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerLocalPermutation;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerLocalPermutation[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_23SamplerLocalPermutation_3sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_23SamplerLocalPermutation_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerLocalPermutation = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerLocalPermutation = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerLocalPermutation = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerLocalPermutation = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerLocalPermutation = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerLocalPermutation"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerLocalPermutation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerLocalPermutation, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerLocalPermutation, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerLocalPermutation, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerLocalPermutation, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerLocalPermutation()\n\n    Sample segments by local permutation.\n\n    This sampler creates a randomized copy of the input\n    set of segmeents by local permutation. The sampler proceeds locally,\n    that is for each continuous part of the workspace separately.\n\n    First, :term:`segments` of the input set overlapping with the current section\n    of the workspace are collected. Then, the order of the segments is randomly\n    permuted and randomly sized gaps inserted. Finally, segments are entered \n    into the workspace from a randomly chosen point. If a segment extends beyond\n    the workspace boundary, it is wrapped around to the start of the\n    workspace.\n\n    If a segment of the input set is extending beyond a workspace boundary, the\n    full sized segment is used for the permutation, but the workspace segment\n    is enlarged by the same amount::\n\n           |-----workspace segment--------------------|\n      1111111      222         333      44444 55555\n      |----------workspace size for permutation-------|\n      33 4444    1111111     55555         222        3   - Random sample 1\n        222     44444 1111111    333   55555              - Random sample 2\n\n\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerLocalPermutation, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_23SamplerLocalPermutation_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerLocalPermutation, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerGlobalPermutation __pyx_vtable_9GatEngine_SamplerGlobalPermutation;

static PyObject *__pyx_tp_new_9GatEngine_SamplerGlobalPermutation(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerGlobalPermutation;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerGlobalPermutation[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_24SamplerGlobalPermutation_3sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_24SamplerGlobalPermutation_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerGlobalPermutation = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerGlobalPermutation = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerGlobalPermutation = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerGlobalPermutation = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerGlobalPermutation = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerGlobalPermutation"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerGlobalPermutation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerGlobalPermutation, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerGlobalPermutation, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerGlobalPermutation, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerGlobalPermutation, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerGlobalPermutation()\n\n    Sample segments by global permutation.\n\n    This sampler creates a randomized copy of the input\n    set of segmeents by permutation. The sampler uses all segments\n    within the workspace.\n\n    First, :term:`segments` of the input set overlapping with the workspace\n    are collected. Then, the order of the segments is randomly\n    permuted and randomly sized gaps inserted. Finally, segments are entered \n    into the workspace from a randomly chosen point. If a segment extends beyond\n    the end of workspace segment it is wrapped around to the start of the next\n    workspace segment. \n\n    If a segment of the input set is extending beyond a workspace boundary, the\n    full sized segment is used for the permutation, but the workspace segment\n    is enlarged by the same amount::\n\n           |--workspace segment--|      |--workspace segment--|\n      1111111      222         333      44444 55555\n      |--------------------------|      |---------------------|  - Workspace used for permutation\n      33 4444    1111111       55       555         222       3  - Random sample 1\n        222     44444 1111111              333   55555           - Random sample 2\n\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerGlobalPermutation, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_24SamplerGlobalPermutation_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerGlobalPermutation, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_SamplerDummy __pyx_vtable_9GatEngine_SamplerDummy;

static PyObject *__pyx_tp_new_9GatEngine_SamplerDummy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplerDummy *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Sampler(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplerDummy *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_SamplerDummy;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplerDummy[] = {
  {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_9GatEngine_12SamplerDummy_3sample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_12SamplerDummy_2sample)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplerDummy = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplerDummy = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplerDummy = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplerDummy = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplerDummy = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplerDummy"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplerDummy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Sampler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplerDummy, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplerDummy, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplerDummy, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplerDummy, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("SamplerDummy()"), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplerDummy, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_12SamplerDummy_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplerDummy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_Counter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_Counter(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_9GatEngine_Counter[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Counter = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Counter = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Counter = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Counter = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_Counter = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.Counter"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_Counter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Counter, /*tp_as_number*/
  &__pyx_tp_as_sequence_Counter, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Counter, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Counter, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("base class for objects that compute counts\n    between two segment lists.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_Counter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_Counter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_CounterNucleotideOverlap(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Counter(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_CounterNucleotideOverlap[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CounterNucleotideOverlap = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CounterNucleotideOverlap = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CounterNucleotideOverlap = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CounterNucleotideOverlap = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_CounterNucleotideOverlap = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.CounterNucleotideOverlap"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_CounterNucleotideOverlap), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CounterNucleotideOverlap, /*tp_as_number*/
  &__pyx_tp_as_sequence_CounterNucleotideOverlap, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CounterNucleotideOverlap, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_9GatEngine_24CounterNucleotideOverlap_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CounterNucleotideOverlap, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_CounterNucleotideOverlap, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_CounterNucleotideOverlap, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_CounterNucleotideDensity(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Counter(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_CounterNucleotideDensity[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CounterNucleotideDensity = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CounterNucleotideDensity = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CounterNucleotideDensity = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CounterNucleotideDensity = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_CounterNucleotideDensity = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.CounterNucleotideDensity"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_CounterNucleotideDensity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CounterNucleotideDensity, /*tp_as_number*/
  &__pyx_tp_as_sequence_CounterNucleotideDensity, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CounterNucleotideDensity, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_9GatEngine_24CounterNucleotideDensity_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CounterNucleotideDensity, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_CounterNucleotideDensity, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_CounterNucleotideDensity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_CounterSegmentOverlap(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Counter(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_CounterSegmentOverlap[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CounterSegmentOverlap = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CounterSegmentOverlap = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CounterSegmentOverlap = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CounterSegmentOverlap = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_CounterSegmentOverlap = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.CounterSegmentOverlap"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_CounterSegmentOverlap), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CounterSegmentOverlap, /*tp_as_number*/
  &__pyx_tp_as_sequence_CounterSegmentOverlap, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CounterSegmentOverlap, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_9GatEngine_21CounterSegmentOverlap_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CounterSegmentOverlap, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_CounterSegmentOverlap, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_CounterSegmentOverlap, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_CounterSegmentMidpointOverlap(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Counter(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_CounterSegmentMidpointOverlap[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CounterSegmentMidpointOverlap = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CounterSegmentMidpointOverlap = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CounterSegmentMidpointOverlap = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CounterSegmentMidpointOverlap = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_CounterSegmentMidpointOverlap = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.CounterSegmentMidpointOverlap"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_CounterSegmentMidpointOverlap), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CounterSegmentMidpointOverlap, /*tp_as_number*/
  &__pyx_tp_as_sequence_CounterSegmentMidpointOverlap, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CounterSegmentMidpointOverlap, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_9GatEngine_29CounterSegmentMidpointOverlap_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CounterSegmentMidpointOverlap, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_CounterSegmentMidpointOverlap, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_CounterSegmentMidpointOverlap, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_CounterAnnotationOverlap(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Counter(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_CounterAnnotationOverlap[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CounterAnnotationOverlap = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CounterAnnotationOverlap = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CounterAnnotationOverlap = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CounterAnnotationOverlap = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_CounterAnnotationOverlap = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.CounterAnnotationOverlap"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_CounterAnnotationOverlap), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CounterAnnotationOverlap, /*tp_as_number*/
  &__pyx_tp_as_sequence_CounterAnnotationOverlap, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CounterAnnotationOverlap, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_9GatEngine_24CounterAnnotationOverlap_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CounterAnnotationOverlap, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_CounterAnnotationOverlap, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_CounterAnnotationOverlap, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_CounterAnnotationMidpointOverlap(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Counter(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_CounterAnnotationMidpointOverlap[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CounterAnnotationMidpointOverlap = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CounterAnnotationMidpointOverlap = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CounterAnnotationMidpointOverlap = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CounterAnnotationMidpointOverlap = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_CounterAnnotationMidpointOverlap = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.CounterAnnotationMidpointOverlap"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_CounterAnnotationMidpointOverlap), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Counter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_CounterAnnotationMidpointOverlap, /*tp_as_number*/
  &__pyx_tp_as_sequence_CounterAnnotationMidpointOverlap, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CounterAnnotationMidpointOverlap, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_9GatEngine_32CounterAnnotationMidpointOverlap_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CounterAnnotationMidpointOverlap, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_CounterAnnotationMidpointOverlap, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_CounterAnnotationMidpointOverlap, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_AnnotatorResult(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_AnnotatorResult *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_AnnotatorResult *)o);
  p->format_observed = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->track = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->annotation = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->counter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_AnnotatorResult(PyObject *o) {
  struct __pyx_obj_9GatEngine_AnnotatorResult *p = (struct __pyx_obj_9GatEngine_AnnotatorResult *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_15AnnotatorResult_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->format_observed);
  Py_CLEAR(p->track);
  Py_CLEAR(p->annotation);
  Py_CLEAR(p->counter);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_AnnotatorResult(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_AnnotatorResult *p = (struct __pyx_obj_9GatEngine_AnnotatorResult *)o;
  if (p->format_observed) {
    e = (*v)(p->format_observed, a); if (e) return e;
  }
  if (p->track) {
    e = (*v)(p->track, a); if (e) return e;
  }
  if (p->annotation) {
    e = (*v)(p->annotation, a); if (e) return e;
  }
  if (p->counter) {
    e = (*v)(p->counter, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_AnnotatorResult(PyObject *o) {
  struct __pyx_obj_9GatEngine_AnnotatorResult *p = (struct __pyx_obj_9GatEngine_AnnotatorResult *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->format_observed);
  p->format_observed = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->track);
  p->track = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->annotation);
  p->annotation = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->counter);
  p->counter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_track(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_5track_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_annotation(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_10annotation_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_counter(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_7counter_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_observed(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_8observed_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_expected(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_8expected_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_fold(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_4fold_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_stddev(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_6stddev_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_pvalue(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_6pvalue_1__get__(o);
}

static int __pyx_setprop_9GatEngine_15AnnotatorResult_pvalue(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9GatEngine_15AnnotatorResult_6pvalue_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_qvalue(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_6qvalue_1__get__(o);
}

static int __pyx_setprop_9GatEngine_15AnnotatorResult_qvalue(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9GatEngine_15AnnotatorResult_6qvalue_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_nsamples(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_8nsamples_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_15AnnotatorResult_samples(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_15AnnotatorResult_7samples_1__get__(o);
}

static int __pyx_setprop_9GatEngine_15AnnotatorResult_format_observed(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9GatEngine_15AnnotatorResult_15format_observed_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_9GatEngine_AnnotatorResult[] = {
  {__Pyx_NAMESTR("isSampleSignificantAtPvalue"), (PyCFunction)__pyx_pw_9GatEngine_15AnnotatorResult_7isSampleSignificantAtPvalue, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_15AnnotatorResult_6isSampleSignificantAtPvalue)},
  {__Pyx_NAMESTR("getSample"), (PyCFunction)__pyx_pw_9GatEngine_15AnnotatorResult_9getSample, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_15AnnotatorResult_8getSample)},
  {__Pyx_NAMESTR("getEmpiricalPValue"), (PyCFunction)__pyx_pw_9GatEngine_15AnnotatorResult_11getEmpiricalPValue, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_15AnnotatorResult_10getEmpiricalPValue)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9GatEngine_AnnotatorResult[] = {
  {(char *)"track", __pyx_getprop_9GatEngine_15AnnotatorResult_track, 0, 0, 0},
  {(char *)"annotation", __pyx_getprop_9GatEngine_15AnnotatorResult_annotation, 0, 0, 0},
  {(char *)"counter", __pyx_getprop_9GatEngine_15AnnotatorResult_counter, 0, 0, 0},
  {(char *)"observed", __pyx_getprop_9GatEngine_15AnnotatorResult_observed, 0, 0, 0},
  {(char *)"expected", __pyx_getprop_9GatEngine_15AnnotatorResult_expected, 0, 0, 0},
  {(char *)"fold", __pyx_getprop_9GatEngine_15AnnotatorResult_fold, 0, 0, 0},
  {(char *)"stddev", __pyx_getprop_9GatEngine_15AnnotatorResult_stddev, 0, 0, 0},
  {(char *)"pvalue", __pyx_getprop_9GatEngine_15AnnotatorResult_pvalue, __pyx_setprop_9GatEngine_15AnnotatorResult_pvalue, 0, 0},
  {(char *)"qvalue", __pyx_getprop_9GatEngine_15AnnotatorResult_qvalue, __pyx_setprop_9GatEngine_15AnnotatorResult_qvalue, 0, 0},
  {(char *)"nsamples", __pyx_getprop_9GatEngine_15AnnotatorResult_nsamples, 0, 0, 0},
  {(char *)"samples", __pyx_getprop_9GatEngine_15AnnotatorResult_samples, 0, 0, 0},
  {(char *)"format_observed", 0, __pyx_setprop_9GatEngine_15AnnotatorResult_format_observed, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_AnnotatorResult = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_AnnotatorResult = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_AnnotatorResult = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_AnnotatorResult = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_AnnotatorResult = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.AnnotatorResult"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_AnnotatorResult), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_AnnotatorResult, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_AnnotatorResult, /*tp_as_number*/
  &__pyx_tp_as_sequence_AnnotatorResult, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_AnnotatorResult, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9GatEngine_15AnnotatorResult_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_AnnotatorResult, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("AnnotatorResult(track, annotation, counter, observed, samples, reference=None, pseudo_count=1.0)\ncontainer for annotator results."), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_AnnotatorResult, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_AnnotatorResult, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_AnnotatorResult, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9GatEngine_AnnotatorResult, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_15AnnotatorResult_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_AnnotatorResult, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_AnnotatorResultExtended(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_AnnotatorResult(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_AnnotatorResultExtended[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_AnnotatorResultExtended = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_AnnotatorResultExtended = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_AnnotatorResultExtended = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_AnnotatorResultExtended = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_AnnotatorResultExtended = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.AnnotatorResultExtended"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_AnnotatorResultExtended), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_AnnotatorResult, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_AnnotatorResultExtended, /*tp_as_number*/
  &__pyx_tp_as_sequence_AnnotatorResultExtended, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_AnnotatorResultExtended, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9GatEngine_23AnnotatorResultExtended_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_AnnotatorResultExtended, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("AnnotatorResultExtended(track, annotation, counter, observed, samples, track_segments, annotation_segments, workspace, reference=None, pseudo_count=1.0)\ncontainer for annotator results."), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_AnnotatorResult, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_AnnotatorResult, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_AnnotatorResultExtended, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_23AnnotatorResultExtended_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_AnnotatorResultExtended, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_TupleProxy __pyx_vtable_9GatEngine_TupleProxy;

static PyObject *__pyx_tp_new_9GatEngine_TupleProxy(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_TupleProxy *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_TupleProxy *)o);
  p->__pyx_vtab = __pyx_vtabptr_9GatEngine_TupleProxy;
  if (__pyx_pw_9GatEngine_10TupleProxy_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_TupleProxy(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_10TupleProxy_7__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_9GatEngine_TupleProxy(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods_9GatEngine_TupleProxy[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_9GatEngine_10TupleProxy_11__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9GatEngine_10TupleProxy_10__next__)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_TupleProxy = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_TupleProxy = {
  __pyx_pw_9GatEngine_10TupleProxy_5__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_9GatEngine_TupleProxy, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_TupleProxy = {
  __pyx_pw_9GatEngine_10TupleProxy_5__len__, /*mp_length*/
  __pyx_pw_9GatEngine_10TupleProxy_3__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_TupleProxy = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_TupleProxy = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.TupleProxy"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_TupleProxy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_TupleProxy, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_TupleProxy, /*tp_as_number*/
  &__pyx_tp_as_sequence_TupleProxy, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_TupleProxy, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_TupleProxy, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("Proxy class for access to parsed row as a tuple.\n\n    This class represents a table row for fast read-access.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_9GatEngine_10TupleProxy_9__iter__, /*tp_iter*/
  __pyx_pw_9GatEngine_10TupleProxy_11__next__, /*tp_iternext*/
  __pyx_methods_9GatEngine_TupleProxy, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_TupleProxy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_9GatEngine_BedProxy __pyx_vtable_9GatEngine_BedProxy;

static PyObject *__pyx_tp_new_9GatEngine_BedProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_BedProxy *p;
  PyObject *o = __pyx_tp_new_9GatEngine_TupleProxy(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_BedProxy *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9GatEngine_TupleProxy*)__pyx_vtabptr_9GatEngine_BedProxy;
  p->track = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_BedProxy(PyObject *o) {
  struct __pyx_obj_9GatEngine_BedProxy *p = (struct __pyx_obj_9GatEngine_BedProxy *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->track);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_9GatEngine_TupleProxy(o);
}

static int __pyx_tp_traverse_9GatEngine_BedProxy(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_BedProxy *p = (struct __pyx_obj_9GatEngine_BedProxy *)o;
  e = ((likely(__pyx_ptype_9GatEngine_TupleProxy)) ? ((__pyx_ptype_9GatEngine_TupleProxy->tp_traverse) ? __pyx_ptype_9GatEngine_TupleProxy->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_9GatEngine_BedProxy)); if (e) return e;
  if (p->track) {
    e = (*v)(p->track, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_BedProxy(PyObject *o) {
  struct __pyx_obj_9GatEngine_BedProxy *p = (struct __pyx_obj_9GatEngine_BedProxy *)o;
  PyObject* tmp;
  if (likely(__pyx_ptype_9GatEngine_TupleProxy)) { if (__pyx_ptype_9GatEngine_TupleProxy->tp_clear) __pyx_ptype_9GatEngine_TupleProxy->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_9GatEngine_BedProxy);
  tmp = ((PyObject*)p->track);
  p->track = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9GatEngine_8BedProxy_contig(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_8BedProxy_6contig_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_8BedProxy_start(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_8BedProxy_5start_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_8BedProxy_end(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_8BedProxy_3end_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_8BedProxy_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_8BedProxy_4name_1__get__(o);
}

static PyObject *__pyx_getprop_9GatEngine_8BedProxy_track(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9GatEngine_8BedProxy_5track_1__get__(o);
}

static PyMethodDef __pyx_methods_9GatEngine_BedProxy[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9GatEngine_BedProxy[] = {
  {(char *)"contig", __pyx_getprop_9GatEngine_8BedProxy_contig, 0, 0, 0},
  {(char *)"start", __pyx_getprop_9GatEngine_8BedProxy_start, 0, 0, 0},
  {(char *)"end", __pyx_getprop_9GatEngine_8BedProxy_end, 0, 0, 0},
  {(char *)"name", __pyx_getprop_9GatEngine_8BedProxy_name, 0, 0, 0},
  {(char *)"track", __pyx_getprop_9GatEngine_8BedProxy_track, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_BedProxy = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_BedProxy = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_10TupleProxy_5__len__, /*sq_length*/
  #else
  0, /*sq_length*/
  #endif
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_BedProxy = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_10TupleProxy_5__len__, /*mp_length*/
  #else
  0, /*mp_length*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_10TupleProxy_3__getitem__, /*mp_subscript*/
  #else
  0, /*mp_subscript*/
  #endif
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_BedProxy = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_BedProxy = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.BedProxy"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_BedProxy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_BedProxy, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_BedProxy, /*tp_as_number*/
  &__pyx_tp_as_sequence_BedProxy, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_BedProxy, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_BedProxy, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("BedProxy(track)"), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_BedProxy, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_BedProxy, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_10TupleProxy_9__iter__, /*tp_iter*/
  #else
  0, /*tp_iter*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_10TupleProxy_11__next__, /*tp_iternext*/
  #else
  0, /*tp_iternext*/
  #endif
  __pyx_methods_9GatEngine_BedProxy, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9GatEngine_BedProxy, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_8BedProxy_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_BedProxy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_Samples(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine_Samples *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_Samples *)o);
  p->samples = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_Samples(PyObject *o) {
  struct __pyx_obj_9GatEngine_Samples *p = (struct __pyx_obj_9GatEngine_Samples *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->samples);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine_Samples(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_Samples *p = (struct __pyx_obj_9GatEngine_Samples *)o;
  if (p->samples) {
    e = (*v)(p->samples, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_Samples(PyObject *o) {
  struct __pyx_obj_9GatEngine_Samples *p = (struct __pyx_obj_9GatEngine_Samples *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->samples);
  p->samples = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_9GatEngine_Samples(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_9GatEngine_Samples(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript assignment not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
  else {
    return __pyx_pw_9GatEngine_7Samples_13__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_9GatEngine_Samples[] = {
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_9GatEngine_7Samples_3add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_7Samples_2add)},
  {__Pyx_NAMESTR("hasSample"), (PyCFunction)__pyx_pw_9GatEngine_7Samples_5hasSample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_7Samples_4hasSample)},
  {__Pyx_NAMESTR("load"), (PyCFunction)__pyx_pw_9GatEngine_7Samples_11load, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_7Samples_10load)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Samples = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Samples = {
  __pyx_pw_9GatEngine_7Samples_15__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_9GatEngine_Samples, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_9GatEngine_7Samples_7__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Samples = {
  __pyx_pw_9GatEngine_7Samples_15__len__, /*mp_length*/
  __pyx_pw_9GatEngine_7Samples_9__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_9GatEngine_Samples, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Samples = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_Samples = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.Samples"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_Samples), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Samples, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Samples, /*tp_as_number*/
  &__pyx_tp_as_sequence_Samples, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Samples, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Samples, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Samples()\na collection of samples.\n\n    Samples :class:`IntervalCollections` identified by track and sample_id.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_Samples, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_Samples, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_Samples, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_7Samples_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_Samples, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_SamplesFile(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_9GatEngine_Samples(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplesFile[] = {
  {__Pyx_NAMESTR("load"), (PyCFunction)__pyx_pw_9GatEngine_11SamplesFile_3load, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_11SamplesFile_2load)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplesFile = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplesFile = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_15__len__, /*sq_length*/
  #else
  0, /*sq_length*/
  #endif
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_7__contains__, /*sq_contains*/
  #else
  0, /*sq_contains*/
  #endif
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplesFile = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_15__len__, /*mp_length*/
  #else
  0, /*mp_length*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_9__getitem__, /*mp_subscript*/
  #else
  0, /*mp_subscript*/
  #endif
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplesFile = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplesFile = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplesFile"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplesFile), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_Samples, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplesFile, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplesFile, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplesFile, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplesFile, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("SamplesFile(filenames, regex)\na collection of samples.\n\n    Samples :class:`IntervalCollections` identified by track and sample_id.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_Samples, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_Samples, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplesFile, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_11SamplesFile_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplesFile, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine_SamplesCached(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9GatEngine_SamplesCached *p;
  PyObject *o = __pyx_tp_new_9GatEngine_Samples(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine_SamplesCached *)o);
  p->index = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9GatEngine_SamplesCached(PyObject *o) {
  struct __pyx_obj_9GatEngine_SamplesCached *p = (struct __pyx_obj_9GatEngine_SamplesCached *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_9GatEngine_13SamplesCached_11__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->index);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_9GatEngine_Samples(o);
}

static int __pyx_tp_traverse_9GatEngine_SamplesCached(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine_SamplesCached *p = (struct __pyx_obj_9GatEngine_SamplesCached *)o;
  e = __pyx_tp_traverse_9GatEngine_Samples(o, v, a); if (e) return e;
  if (p->index) {
    e = (*v)(p->index, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine_SamplesCached(PyObject *o) {
  struct __pyx_obj_9GatEngine_SamplesCached *p = (struct __pyx_obj_9GatEngine_SamplesCached *)o;
  PyObject* tmp;
  __pyx_tp_clear_9GatEngine_Samples(o);
  tmp = ((PyObject*)p->index);
  p->index = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine_SamplesCached[] = {
  {__Pyx_NAMESTR("loadIndex"), (PyCFunction)__pyx_pw_9GatEngine_13SamplesCached_3loadIndex, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_13SamplesCached_2loadIndex)},
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_9GatEngine_13SamplesCached_5add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_13SamplesCached_4add)},
  {__Pyx_NAMESTR("toKey"), (PyCFunction)__pyx_pw_9GatEngine_13SamplesCached_7toKey, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_13SamplesCached_6toKey)},
  {__Pyx_NAMESTR("hasSample"), (PyCFunction)__pyx_pw_9GatEngine_13SamplesCached_9hasSample, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_13SamplesCached_8hasSample)},
  {__Pyx_NAMESTR("load"), (PyCFunction)__pyx_pw_9GatEngine_13SamplesCached_13load, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_13SamplesCached_12load)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SamplesCached = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SamplesCached = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_15__len__, /*sq_length*/
  #else
  0, /*sq_length*/
  #endif
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_7__contains__, /*sq_contains*/
  #else
  0, /*sq_contains*/
  #endif
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SamplesCached = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_15__len__, /*mp_length*/
  #else
  0, /*mp_length*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_9GatEngine_7Samples_9__getitem__, /*mp_subscript*/
  #else
  0, /*mp_subscript*/
  #endif
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SamplesCached = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine_SamplesCached = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.SamplesCached"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine_SamplesCached), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine_SamplesCached, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_SamplesCached, /*tp_as_number*/
  &__pyx_tp_as_sequence_SamplesCached, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SamplesCached, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SamplesCached, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("SamplesCached(filename)\na collection of samples.\n\n    Samples :class:`IntervalCollections` identified by track and sample_id.\n    "), /*tp_doc*/
  __pyx_tp_traverse_9GatEngine_SamplesCached, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine_SamplesCached, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine_SamplesCached, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9GatEngine_13SamplesCached_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine_SamplesCached, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine___pyx_scope_struct____str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *)o);
  p->__pyx_v_self = 0;
  return o;
}

static void __pyx_tp_dealloc_9GatEngine___pyx_scope_struct____str__(PyObject *o) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine___pyx_scope_struct____str__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine___pyx_scope_struct____str__(PyObject *o) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct____str__ *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9GatEngine_AnnotatorResultExtended *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine___pyx_scope_struct____str__[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct____str__ = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct____str__ = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct____str__ = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct____str__ = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine___pyx_scope_struct____str__ = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.__pyx_scope_struct____str__"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine___pyx_scope_struct____str__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine___pyx_scope_struct____str__, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number___pyx_scope_struct____str__, /*tp_as_number*/
  &__pyx_tp_as_sequence___pyx_scope_struct____str__, /*tp_as_sequence*/
  &__pyx_tp_as_mapping___pyx_scope_struct____str__, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer___pyx_scope_struct____str__, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9GatEngine___pyx_scope_struct____str__, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine___pyx_scope_struct____str__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine___pyx_scope_struct____str__, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine___pyx_scope_struct____str__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine___pyx_scope_struct_1_getSegmentLists(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *)o);
  p->__pyx_v_contig = 0;
  p->__pyx_v_segmentlist = 0;
  p->__pyx_v_self = 0;
  p->__pyx_t_0 = 0;
  return o;
}

static void __pyx_tp_dealloc_9GatEngine___pyx_scope_struct_1_getSegmentLists(PyObject *o) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_contig);
  Py_CLEAR(p->__pyx_v_segmentlist);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine___pyx_scope_struct_1_getSegmentLists(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *)o;
  if (p->__pyx_v_contig) {
    e = (*v)(p->__pyx_v_contig, a); if (e) return e;
  }
  if (p->__pyx_v_segmentlist) {
    e = (*v)(p->__pyx_v_segmentlist, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine___pyx_scope_struct_1_getSegmentLists(PyObject *o) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->__pyx_v_contig);
  p->__pyx_v_contig = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_segmentlist);
  p->__pyx_v_segmentlist = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9GatEngine_IntervalDictionary *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine___pyx_scope_struct_1_getSegmentLists[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1_getSegmentLists = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_1_getSegmentLists = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_1_getSegmentLists = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1_getSegmentLists = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine___pyx_scope_struct_1_getSegmentLists = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.__pyx_scope_struct_1_getSegmentLists"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine___pyx_scope_struct_1_getSegmentLists), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine___pyx_scope_struct_1_getSegmentLists, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number___pyx_scope_struct_1_getSegmentLists, /*tp_as_number*/
  &__pyx_tp_as_sequence___pyx_scope_struct_1_getSegmentLists, /*tp_as_sequence*/
  &__pyx_tp_as_mapping___pyx_scope_struct_1_getSegmentLists, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer___pyx_scope_struct_1_getSegmentLists, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9GatEngine___pyx_scope_struct_1_getSegmentLists, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine___pyx_scope_struct_1_getSegmentLists, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine___pyx_scope_struct_1_getSegmentLists, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine___pyx_scope_struct_1_getSegmentLists, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_9GatEngine___pyx_scope_struct_2_getSegmentLists(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *)o);
  p->__pyx_v_contig = 0;
  p->__pyx_v_segmentlist = 0;
  p->__pyx_v_self = 0;
  p->__pyx_v_track = 0;
  p->__pyx_v_v = 0;
  p->__pyx_t_0 = 0;
  p->__pyx_t_4 = 0;
  return o;
}

static void __pyx_tp_dealloc_9GatEngine___pyx_scope_struct_2_getSegmentLists(PyObject *o) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_contig);
  Py_CLEAR(p->__pyx_v_segmentlist);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_track);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_4);
  PyObject_GC_Track(o);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9GatEngine___pyx_scope_struct_2_getSegmentLists(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *)o;
  if (p->__pyx_v_contig) {
    e = (*v)(p->__pyx_v_contig, a); if (e) return e;
  }
  if (p->__pyx_v_segmentlist) {
    e = (*v)(p->__pyx_v_segmentlist, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_track) {
    e = (*v)(p->__pyx_v_track, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9GatEngine___pyx_scope_struct_2_getSegmentLists(PyObject *o) {
  struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *p = (struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->__pyx_v_contig);
  p->__pyx_v_contig = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_segmentlist);
  p->__pyx_v_segmentlist = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9GatEngine_IntervalCollection *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_track);
  p->__pyx_v_track = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_v);
  p->__pyx_v_v = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_4);
  p->__pyx_t_4 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_9GatEngine___pyx_scope_struct_2_getSegmentLists[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2_getSegmentLists = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_2_getSegmentLists = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_2_getSegmentLists = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2_getSegmentLists = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_9GatEngine___pyx_scope_struct_2_getSegmentLists = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("GatEngine.__pyx_scope_struct_2_getSegmentLists"), /*tp_name*/
  sizeof(struct __pyx_obj_9GatEngine___pyx_scope_struct_2_getSegmentLists), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9GatEngine___pyx_scope_struct_2_getSegmentLists, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number___pyx_scope_struct_2_getSegmentLists, /*tp_as_number*/
  &__pyx_tp_as_sequence___pyx_scope_struct_2_getSegmentLists, /*tp_as_sequence*/
  &__pyx_tp_as_mapping___pyx_scope_struct_2_getSegmentLists, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer___pyx_scope_struct_2_getSegmentLists, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9GatEngine___pyx_scope_struct_2_getSegmentLists, /*tp_traverse*/
  __pyx_tp_clear_9GatEngine___pyx_scope_struct_2_getSegmentLists, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9GatEngine___pyx_scope_struct_2_getSegmentLists, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9GatEngine___pyx_scope_struct_2_getSegmentLists, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("getNPTwoSidedPValue"), (PyCFunction)__pyx_pw_9GatEngine_11getNPTwoSidedPValue, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9GatEngine_10getNPTwoSidedPValue)},
  {__Pyx_NAMESTR("computeFDR"), (PyCFunction)__pyx_pw_9GatEngine_41computeFDR, METH_O, __Pyx_DOCSTR(__pyx_doc_9GatEngine_40computeFDR)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("GatEngine"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_n_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 1},
  {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
  {&__pyx_kp_s_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 1, 0},
  {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
  {&__pyx_kp_u_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 1, 0, 0},
  {&__pyx_kp_u_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 1, 0, 0},
  {&__pyx_kp_u_107, __pyx_k_107, sizeof(__pyx_k_107), 0, 1, 0, 0},
  {&__pyx_kp_u_109, __pyx_k_109, sizeof(__pyx_k_109), 0, 1, 0, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_u_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 1, 0, 0},
  {&__pyx_kp_u_113, __pyx_k_113, sizeof(__pyx_k_113), 0, 1, 0, 0},
  {&__pyx_n_s_115, __pyx_k_115, sizeof(__pyx_k_115), 0, 0, 1, 1},
  {&__pyx_n_s_116, __pyx_k_116, sizeof(__pyx_k_116), 0, 0, 1, 1},
  {&__pyx_n_s_117, __pyx_k_117, sizeof(__pyx_k_117), 0, 0, 1, 1},
  {&__pyx_n_s_118, __pyx_k_118, sizeof(__pyx_k_118), 0, 0, 1, 1},
  {&__pyx_n_s_119, __pyx_k_119, sizeof(__pyx_k_119), 0, 0, 1, 1},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_n_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 1},
  {&__pyx_kp_s_130, __pyx_k_130, sizeof(__pyx_k_130), 0, 0, 1, 0},
  {&__pyx_kp_s_131, __pyx_k_131, sizeof(__pyx_k_131), 0, 0, 1, 0},
  {&__pyx_kp_s_132, __pyx_k_132, sizeof(__pyx_k_132), 0, 0, 1, 0},
  {&__pyx_kp_s_133, __pyx_k_133, sizeof(__pyx_k_133), 0, 0, 1, 0},
  {&__pyx_kp_s_134, __pyx_k_134, sizeof(__pyx_k_134), 0, 0, 1, 0},
  {&__pyx_kp_s_135, __pyx_k_135, sizeof(__pyx_k_135), 0, 0, 1, 0},
  {&__pyx_n_s_138, __pyx_k_138, sizeof(__pyx_k_138), 0, 0, 1, 1},
  {&__pyx_kp_s_139, __pyx_k_139, sizeof(__pyx_k_139), 0, 0, 1, 0},
  {&__pyx_kp_s_140, __pyx_k_140, sizeof(__pyx_k_140), 0, 0, 1, 0},
  {&__pyx_n_s_141, __pyx_k_141, sizeof(__pyx_k_141), 0, 0, 1, 1},
  {&__pyx_n_s_142, __pyx_k_142, sizeof(__pyx_k_142), 0, 0, 1, 1},
  {&__pyx_n_s_143, __pyx_k_143, sizeof(__pyx_k_143), 0, 0, 1, 1},
  {&__pyx_n_s_144, __pyx_k_144, sizeof(__pyx_k_144), 0, 0, 1, 1},
  {&__pyx_n_s_145, __pyx_k_145, sizeof(__pyx_k_145), 0, 0, 1, 1},
  {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1},
  {&__pyx_n_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 1},
  {&__pyx_kp_s_160, __pyx_k_160, sizeof(__pyx_k_160), 0, 0, 1, 0},
  {&__pyx_n_s_161, __pyx_k_161, sizeof(__pyx_k_161), 0, 0, 1, 1},
  {&__pyx_kp_s_164, __pyx_k_164, sizeof(__pyx_k_164), 0, 0, 1, 0},
  {&__pyx_n_s_165, __pyx_k_165, sizeof(__pyx_k_165), 0, 0, 1, 1},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_kp_s_171, __pyx_k_171, sizeof(__pyx_k_171), 0, 0, 1, 0},
  {&__pyx_n_s_172, __pyx_k_172, sizeof(__pyx_k_172), 0, 0, 1, 1},
  {&__pyx_kp_s_175, __pyx_k_175, sizeof(__pyx_k_175), 0, 0, 1, 0},
  {&__pyx_n_s_176, __pyx_k_176, sizeof(__pyx_k_176), 0, 0, 1, 1},
  {&__pyx_kp_s_179, __pyx_k_179, sizeof(__pyx_k_179), 0, 0, 1, 0},
  {&__pyx_n_s_180, __pyx_k_180, sizeof(__pyx_k_180), 0, 0, 1, 1},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_s_196, __pyx_k_196, sizeof(__pyx_k_196), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_n_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 1},
  {&__pyx_kp_s_207, __pyx_k_207, sizeof(__pyx_k_207), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
  {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
  {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
  {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
  {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
  {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
  {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
  {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
  {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
  {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
  {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
  {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0},
  {&__pyx_kp_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 0},
  {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
  {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0},
  {&__pyx_n_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 1},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 1, 0},
  {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
  {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 0},
  {&__pyx_kp_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 0},
  {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
  {&__pyx_kp_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 0},
  {&__pyx_kp_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 0},
  {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_n_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 1},
  {&__pyx_kp_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 0},
  {&__pyx_kp_s_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 1, 0},
  {&__pyx_kp_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 0},
  {&__pyx_kp_s_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 0, 1, 0},
  {&__pyx_n_s_78, __pyx_k_78, sizeof(__pyx_k_78), 0, 0, 1, 1},
  {&__pyx_kp_s_80, __pyx_k_80, sizeof(__pyx_k_80), 0, 0, 1, 0},
  {&__pyx_kp_s_81, __pyx_k_81, sizeof(__pyx_k_81), 0, 0, 1, 0},
  {&__pyx_kp_s_82, __pyx_k_82, sizeof(__pyx_k_82), 0, 0, 1, 0},
  {&__pyx_kp_s_83, __pyx_k_83, sizeof(__pyx_k_83), 0, 0, 1, 0},
  {&__pyx_kp_s_84, __pyx_k_84, sizeof(__pyx_k_84), 0, 0, 1, 0},
  {&__pyx_kp_s_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 1, 0},
  {&__pyx_kp_s_87, __pyx_k_87, sizeof(__pyx_k_87), 0, 0, 1, 0},
  {&__pyx_n_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 1},
  {&__pyx_kp_s_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 1, 0},
  {&__pyx_kp_s_91, __pyx_k_91, sizeof(__pyx_k_91), 0, 0, 1, 0},
  {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
  {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
  {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0},
  {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
  {&__pyx_kp_s_98, __pyx_k_98, sizeof(__pyx_k_98), 0, 0, 1, 0},
  {&__pyx_kp_s_99, __pyx_k_99, sizeof(__pyx_k_99), 0, 0, 1, 0},
  {&__pyx_n_s__CI95high, __pyx_k__CI95high, sizeof(__pyx_k__CI95high), 0, 0, 1, 1},
  {&__pyx_n_s__CI95low, __pyx_k__CI95low, sizeof(__pyx_k__CI95low), 0, 0, 1, 1},
  {&__pyx_n_s__DTYPE_FLOAT, __pyx_k__DTYPE_FLOAT, sizeof(__pyx_k__DTYPE_FLOAT), 0, 0, 1, 1},
  {&__pyx_n_s__DTYPE_INT, __pyx_k__DTYPE_INT, sizeof(__pyx_k__DTYPE_INT), 0, 0, 1, 1},
  {&__pyx_n_s__E, __pyx_k__E, sizeof(__pyx_k__E), 0, 0, 1, 1},
  {&__pyx_n_s__GatEngine, __pyx_k__GatEngine, sizeof(__pyx_k__GatEngine), 0, 0, 1, 1},
  {&__pyx_n_s__GatSegmentList, __pyx_k__GatSegmentList, sizeof(__pyx_k__GatSegmentList), 0, 0, 1, 1},
  {&__pyx_n_s__HAS_SCIPY, __pyx_k__HAS_SCIPY, sizeof(__pyx_k__HAS_SCIPY), 0, 0, 1, 1},
  {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
  {&__pyx_n_s__IOTools, __pyx_k__IOTools, sizeof(__pyx_k__IOTools), 0, 0, 1, 1},
  {&__pyx_n_s__ImportError, __pyx_k__ImportError, sizeof(__pyx_k__ImportError), 0, 0, 1, 1},
  {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1},
  {&__pyx_n_s__OSError, __pyx_k__OSError, sizeof(__pyx_k__OSError), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__Stats, __pyx_k__Stats, sizeof(__pyx_k__Stats), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s__Track, __pyx_k__Track, sizeof(__pyx_k__Track), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s___, __pyx_k___, sizeof(__pyx_k___), 0, 0, 1, 1},
  {&__pyx_n_s____call__, __pyx_k____call__, sizeof(__pyx_k____call__), 0, 0, 1, 1},
  {&__pyx_n_s____getitem__, __pyx_k____getitem__, sizeof(__pyx_k____getitem__), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____iter__, __pyx_k____iter__, sizeof(__pyx_k____iter__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____setitem__, __pyx_k____setitem__, sizeof(__pyx_k____setitem__), 0, 0, 1, 1},
  {&__pyx_n_s____str__, __pyx_k____str__, sizeof(__pyx_k____str__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___append, __pyx_k___append, sizeof(__pyx_k___append), 0, 0, 1, 1},
  {&__pyx_n_s___d, __pyx_k___d, sizeof(__pyx_k___d), 0, 0, 1, 1},
  {&__pyx_n_s___defdictfloat, __pyx_k___defdictfloat, sizeof(__pyx_k___defdictfloat), 0, 0, 1, 1},
  {&__pyx_n_s___genie, __pyx_k___genie, sizeof(__pyx_k___genie), 0, 0, 1, 1},
  {&__pyx_n_s___line, __pyx_k___line, sizeof(__pyx_k___line), 0, 0, 1, 1},
  {&__pyx_n_s___set, __pyx_k___set, sizeof(__pyx_k___set), 0, 0, 1, 1},
  {&__pyx_n_s___toDensity, __pyx_k___toDensity, sizeof(__pyx_k___toDensity), 0, 0, 1, 1},
  {&__pyx_n_s___toFold, __pyx_k___toFold, sizeof(__pyx_k___toFold), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__absval, __pyx_k__absval, sizeof(__pyx_k__absval), 0, 0, 1, 1},
  {&__pyx_n_s__add, __pyx_k__add, sizeof(__pyx_k__add), 0, 0, 1, 1},
  {&__pyx_n_s__adjustPValues, __pyx_k__adjustPValues, sizeof(__pyx_k__adjustPValues), 0, 0, 1, 1},
  {&__pyx_n_s__aggregator, __pyx_k__aggregator, sizeof(__pyx_k__aggregator), 0, 0, 1, 1},
  {&__pyx_n_s__allocate, __pyx_k__allocate, sizeof(__pyx_k__allocate), 0, 0, 1, 1},
  {&__pyx_n_s__allow_multiple, __pyx_k__allow_multiple, sizeof(__pyx_k__allow_multiple), 0, 0, 1, 1},
  {&__pyx_n_s__annos, __pyx_k__annos, sizeof(__pyx_k__annos), 0, 0, 1, 1},
  {&__pyx_n_s__annotation, __pyx_k__annotation, sizeof(__pyx_k__annotation), 0, 0, 1, 1},
  {&__pyx_n_s__annotation_density, __pyx_k__annotation_density, sizeof(__pyx_k__annotation_density), 0, 0, 1, 1},
  {&__pyx_n_s__annotation_segments, __pyx_k__annotation_segments, sizeof(__pyx_k__annotation_segments), 0, 0, 1, 1},
  {&__pyx_n_s__annotation_size, __pyx_k__annotation_size, sizeof(__pyx_k__annotation_size), 0, 0, 1, 1},
  {&__pyx_n_s__annotations, __pyx_k__annotations, sizeof(__pyx_k__annotations), 0, 0, 1, 1},
  {&__pyx_n_s__annotator_results, __pyx_k__annotator_results, sizeof(__pyx_k__annotator_results), 0, 0, 1, 1},
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__ar, __pyx_k__ar, sizeof(__pyx_k__ar), 0, 0, 1, 1},
  {&__pyx_n_s__arange, __pyx_k__arange, sizeof(__pyx_k__arange), 0, 0, 1, 1},
  {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1},
  {&__pyx_n_s__argsort, __pyx_k__argsort, sizeof(__pyx_k__argsort), 0, 0, 1, 1},
  {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 0, 0, 1, 1},
  {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
  {&__pyx_n_s__basename, __pyx_k__basename, sizeof(__pyx_k__basename), 0, 0, 1, 1},
  {&__pyx_n_s__bed, __pyx_k__bed, sizeof(__pyx_k__bed), 0, 0, 1, 1},
  {&__pyx_n_s__bed_iterator, __pyx_k__bed_iterator, sizeof(__pyx_k__bed_iterator), 0, 0, 1, 1},
  {&__pyx_n_s__bucket_size, __pyx_k__bucket_size, sizeof(__pyx_k__bucket_size), 0, 0, 1, 1},
  {&__pyx_n_s__buildSamplerShift, __pyx_k__buildSamplerShift, sizeof(__pyx_k__buildSamplerShift), 0, 0, 1, 1},
  {&__pyx_n_s__buildSamplerUniform, __pyx_k__buildSamplerUniform, sizeof(__pyx_k__buildSamplerUniform), 0, 0, 1, 1},
  {&__pyx_n_s__cdf, __pyx_k__cdf, sizeof(__pyx_k__cdf), 0, 0, 1, 1},
  {&__pyx_n_s__clone, __pyx_k__clone, sizeof(__pyx_k__clone), 0, 0, 1, 1},
  {&__pyx_n_s__collapsed, __pyx_k__collapsed, sizeof(__pyx_k__collapsed), 0, 0, 1, 1},
  {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1},
  {&__pyx_n_s__compile, __pyx_k__compile, sizeof(__pyx_k__compile), 0, 0, 1, 1},
  {&__pyx_n_s__computeCounts, __pyx_k__computeCounts, sizeof(__pyx_k__computeCounts), 0, 0, 1, 1},
  {&__pyx_n_s__computeQValues, __pyx_k__computeQValues, sizeof(__pyx_k__computeQValues), 0, 0, 1, 1},
  {&__pyx_n_s__contig, __pyx_k__contig, sizeof(__pyx_k__contig), 0, 0, 1, 1},
  {&__pyx_n_s__counter, __pyx_k__counter, sizeof(__pyx_k__counter), 0, 0, 1, 1},
  {&__pyx_n_s__counts, __pyx_k__counts, sizeof(__pyx_k__counts), 0, 0, 1, 1},
  {&__pyx_n_s__create, __pyx_k__create, sizeof(__pyx_k__create), 0, 0, 1, 1},
  {&__pyx_n_s__cumsum, __pyx_k__cumsum, sizeof(__pyx_k__cumsum), 0, 0, 1, 1},
  {&__pyx_n_s__current_orientation, __pyx_k__current_orientation, sizeof(__pyx_k__current_orientation), 0, 0, 1, 1},
  {&__pyx_n_s__current_position, __pyx_k__current_position, sizeof(__pyx_k__current_position), 0, 0, 1, 1},
  {&__pyx_n_s__current_workspace, __pyx_k__current_workspace, sizeof(__pyx_k__current_workspace), 0, 0, 1, 1},
  {&__pyx_n_s__debug, __pyx_k__debug, sizeof(__pyx_k__debug), 0, 0, 1, 1},
  {&__pyx_n_s__default_name, __pyx_k__default_name, sizeof(__pyx_k__default_name), 0, 0, 1, 1},
  {&__pyx_n_s__defaultdict, __pyx_k__defaultdict, sizeof(__pyx_k__defaultdict), 0, 0, 1, 1},
  {&__pyx_n_s__delete, __pyx_k__delete, sizeof(__pyx_k__delete), 0, 0, 1, 1},
  {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1},
  {&__pyx_n_s__empirical, __pyx_k__empirical, sizeof(__pyx_k__empirical), 0, 0, 1, 1},
  {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
  {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
  {&__pyx_n_s__expand, __pyx_k__expand, sizeof(__pyx_k__expand), 0, 0, 1, 1},
  {&__pyx_n_s__expansion, __pyx_k__expansion, sizeof(__pyx_k__expansion), 0, 0, 1, 1},
  {&__pyx_n_s__expected, __pyx_k__expected, sizeof(__pyx_k__expected), 0, 0, 1, 1},
  {&__pyx_n_s__extend, __pyx_k__extend, sizeof(__pyx_k__extend), 0, 0, 1, 1},
  {&__pyx_n_s__extension, __pyx_k__extension, sizeof(__pyx_k__extension), 0, 0, 1, 1},
  {&__pyx_n_s__f, __pyx_k__f, sizeof(__pyx_k__f), 0, 0, 1, 1},
  {&__pyx_n_s__fdr, __pyx_k__fdr, sizeof(__pyx_k__fdr), 0, 0, 1, 1},
  {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
  {&__pyx_n_s__filenames, __pyx_k__filenames, sizeof(__pyx_k__filenames), 0, 0, 1, 1},
  {&__pyx_n_s__filter, __pyx_k__filter, sizeof(__pyx_k__filter), 0, 0, 1, 1},
  {&__pyx_n_s__findall, __pyx_k__findall, sizeof(__pyx_k__findall), 0, 0, 1, 1},
  {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1},
  {&__pyx_n_s__fold, __pyx_k__fold, sizeof(__pyx_k__fold), 0, 0, 1, 1},
  {&__pyx_n_s__format_counts, __pyx_k__format_counts, sizeof(__pyx_k__format_counts), 0, 0, 1, 1},
  {&__pyx_n_s__format_density, __pyx_k__format_density, sizeof(__pyx_k__format_density), 0, 0, 1, 1},
  {&__pyx_n_s__format_expected, __pyx_k__format_expected, sizeof(__pyx_k__format_expected), 0, 0, 1, 1},
  {&__pyx_n_s__format_fold, __pyx_k__format_fold, sizeof(__pyx_k__format_fold), 0, 0, 1, 1},
  {&__pyx_n_s__format_pvalue, __pyx_k__format_pvalue, sizeof(__pyx_k__format_pvalue), 0, 0, 1, 1},
  {&__pyx_n_s__fromIsochores, __pyx_k__fromIsochores, sizeof(__pyx_k__fromIsochores), 0, 0, 1, 1},
  {&__pyx_n_s__gat, __pyx_k__gat, sizeof(__pyx_k__gat), 0, 0, 1, 1},
  {&__pyx_n_s__getCenter, __pyx_k__getCenter, sizeof(__pyx_k__getCenter), 0, 0, 1, 1},
  {&__pyx_n_s__getEmpiricalPValue, __pyx_k__getEmpiricalPValue, sizeof(__pyx_k__getEmpiricalPValue), 0, 0, 1, 1},
  {&__pyx_n_s__getNormedPValue, __pyx_k__getNormedPValue, sizeof(__pyx_k__getNormedPValue), 0, 0, 1, 1},
  {&__pyx_n_s__getQValues, __pyx_k__getQValues, sizeof(__pyx_k__getQValues), 0, 0, 1, 1},
  {&__pyx_n_s__getSegmentLists, __pyx_k__getSegmentLists, sizeof(__pyx_k__getSegmentLists), 0, 0, 1, 1},
  {&__pyx_n_s__getpid, __pyx_k__getpid, sizeof(__pyx_k__getpid), 0, 0, 1, 1},
  {&__pyx_n_s__groups, __pyx_k__groups, sizeof(__pyx_k__groups), 0, 0, 1, 1},
  {&__pyx_n_s__headers, __pyx_k__headers, sizeof(__pyx_k__headers), 0, 0, 1, 1},
  {&__pyx_n_s__histogram, __pyx_k__histogram, sizeof(__pyx_k__histogram), 0, 0, 1, 1},
  {&__pyx_n_s__increment, __pyx_k__increment, sizeof(__pyx_k__increment), 0, 0, 1, 1},
  {&__pyx_n_s__infile, __pyx_k__infile, sizeof(__pyx_k__infile), 0, 0, 1, 1},
  {&__pyx_n_s__int, __pyx_k__int, sizeof(__pyx_k__int), 0, 0, 1, 1},
  {&__pyx_n_s__intersect, __pyx_k__intersect, sizeof(__pyx_k__intersect), 0, 0, 1, 1},
  {&__pyx_n_s__isNormalized, __pyx_k__isNormalized, sizeof(__pyx_k__isNormalized), 0, 0, 1, 1},
  {&__pyx_n_s__is_conditional, __pyx_k__is_conditional, sizeof(__pyx_k__is_conditional), 0, 0, 1, 1},
  {&__pyx_n_s__isochore, __pyx_k__isochore, sizeof(__pyx_k__isochore), 0, 0, 1, 1},
  {&__pyx_n_s__isochores, __pyx_k__isochores, sizeof(__pyx_k__isochores), 0, 0, 1, 1},
  {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
  {&__pyx_n_s__iteritems, __pyx_k__iteritems, sizeof(__pyx_k__iteritems), 0, 0, 1, 1},
  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
  {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1},
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
  {&__pyx_n_s__kwargs, __pyx_k__kwargs, sizeof(__pyx_k__kwargs), 0, 0, 1, 1},
  {&__pyx_n_s__l, __pyx_k__l, sizeof(__pyx_k__l), 0, 0, 1, 1},
  {&__pyx_n_s__l2fold, __pyx_k__l2fold, sizeof(__pyx_k__l2fold), 0, 0, 1, 1},
  {&__pyx_n_s__line, __pyx_k__line, sizeof(__pyx_k__line), 0, 0, 1, 1},
  {&__pyx_n_s__lineno, __pyx_k__lineno, sizeof(__pyx_k__lineno), 0, 0, 1, 1},
  {&__pyx_n_s__load, __pyx_k__load, sizeof(__pyx_k__load), 0, 0, 1, 1},
  {&__pyx_n_s__loadIndex, __pyx_k__loadIndex, sizeof(__pyx_k__loadIndex), 0, 0, 1, 1},
  {&__pyx_n_s__log, __pyx_k__log, sizeof(__pyx_k__log), 0, 0, 1, 1},
  {&__pyx_n_s__math, __pyx_k__math, sizeof(__pyx_k__math), 0, 0, 1, 1},
  {&__pyx_n_s__mean, __pyx_k__mean, sizeof(__pyx_k__mean), 0, 0, 1, 1},
  {&__pyx_n_s__merge, __pyx_k__merge, sizeof(__pyx_k__merge), 0, 0, 1, 1},
  {&__pyx_n_s__merged, __pyx_k__merged, sizeof(__pyx_k__merged), 0, 0, 1, 1},
  {&__pyx_n_s__method, __pyx_k__method, sizeof(__pyx_k__method), 0, 0, 1, 1},
  {&__pyx_n_s__methodf, __pyx_k__methodf, sizeof(__pyx_k__methodf), 0, 0, 1, 1},
  {&__pyx_n_s__midpoint, __pyx_k__midpoint, sizeof(__pyx_k__midpoint), 0, 0, 1, 1},
  {&__pyx_n_s__min_pval, __pyx_k__min_pval, sizeof(__pyx_k__min_pval), 0, 0, 1, 1},
  {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
  {&__pyx_n_s__msg, __pyx_k__msg, sizeof(__pyx_k__msg), 0, 0, 1, 1},
  {&__pyx_n_s__na, __pyx_k__na, sizeof(__pyx_k__na), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__nbuckets, __pyx_k__nbuckets, sizeof(__pyx_k__nbuckets), 0, 0, 1, 1},
  {&__pyx_n_s__nbytes, __pyx_k__nbytes, sizeof(__pyx_k__nbytes), 0, 0, 1, 1},
  {&__pyx_n_s__next, __pyx_k__next, sizeof(__pyx_k__next), 0, 0, 1, 1},
  {&__pyx_n_s__norm, __pyx_k__norm, sizeof(__pyx_k__norm), 0, 0, 1, 1},
  {&__pyx_n_s__normalize, __pyx_k__normalize, sizeof(__pyx_k__normalize), 0, 0, 1, 1},
  {&__pyx_n_s__nsamples, __pyx_k__nsamples, sizeof(__pyx_k__nsamples), 0, 0, 1, 1},
  {&__pyx_n_s__ntries_inner, __pyx_k__ntries_inner, sizeof(__pyx_k__ntries_inner), 0, 0, 1, 1},
  {&__pyx_n_s__ntries_outer, __pyx_k__ntries_outer, sizeof(__pyx_k__ntries_outer), 0, 0, 1, 1},
  {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1},
  {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
  {&__pyx_n_s__observed, __pyx_k__observed, sizeof(__pyx_k__observed), 0, 0, 1, 1},
  {&__pyx_n_s__openFile, __pyx_k__openFile, sizeof(__pyx_k__openFile), 0, 0, 1, 1},
  {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
  {&__pyx_n_s__other, __pyx_k__other, sizeof(__pyx_k__other), 0, 0, 1, 1},
  {&__pyx_n_s__outfile, __pyx_k__outfile, sizeof(__pyx_k__outfile), 0, 0, 1, 1},
  {&__pyx_n_s__overlapWithSegments, __pyx_k__overlapWithSegments, sizeof(__pyx_k__overlapWithSegments), 0, 0, 1, 1},
  {&__pyx_n_s__overlap_density, __pyx_k__overlap_density, sizeof(__pyx_k__overlap_density), 0, 0, 1, 1},
  {&__pyx_n_s__overlap_nsegments, __pyx_k__overlap_nsegments, sizeof(__pyx_k__overlap_nsegments), 0, 0, 1, 1},
  {&__pyx_n_s__overlap_size, __pyx_k__overlap_size, sizeof(__pyx_k__overlap_size), 0, 0, 1, 1},
  {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
  {&__pyx_n_s__pi0_method, __pyx_k__pi0_method, sizeof(__pyx_k__pi0_method), 0, 0, 1, 1},
  {&__pyx_n_s__prefix, __pyx_k__prefix, sizeof(__pyx_k__prefix), 0, 0, 1, 1},
  {&__pyx_n_s__preparse, __pyx_k__preparse, sizeof(__pyx_k__preparse), 0, 0, 1, 1},
  {&__pyx_n_s__property, __pyx_k__property, sizeof(__pyx_k__property), 0, 0, 1, 1},
  {&__pyx_n_s__pseudo_count, __pyx_k__pseudo_count, sizeof(__pyx_k__pseudo_count), 0, 0, 1, 1},
  {&__pyx_n_s__pval, __pyx_k__pval, sizeof(__pyx_k__pval), 0, 0, 1, 1},
  {&__pyx_n_s__pvalue, __pyx_k__pvalue, sizeof(__pyx_k__pvalue), 0, 0, 1, 1},
  {&__pyx_n_s__pvalues, __pyx_k__pvalues, sizeof(__pyx_k__pvalues), 0, 0, 1, 1},
  {&__pyx_n_s__qvalue, __pyx_k__qvalue, sizeof(__pyx_k__qvalue), 0, 0, 1, 1},
  {&__pyx_n_s__qvalues, __pyx_k__qvalues, sizeof(__pyx_k__qvalues), 0, 0, 1, 1},
  {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
  {&__pyx_n_s__radius, __pyx_k__radius, sizeof(__pyx_k__radius), 0, 0, 1, 1},
  {&__pyx_n_s__randint, __pyx_k__randint, sizeof(__pyx_k__randint), 0, 0, 1, 1},
  {&__pyx_n_s__random, __pyx_k__random, sizeof(__pyx_k__random), 0, 0, 1, 1},
  {&__pyx_n_s__random_sample, __pyx_k__random_sample, sizeof(__pyx_k__random_sample), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__re, __pyx_k__re, sizeof(__pyx_k__re), 0, 0, 1, 1},
  {&__pyx_n_s__readFromBed, __pyx_k__readFromBed, sizeof(__pyx_k__readFromBed), 0, 0, 1, 1},
  {&__pyx_n_s__readline, __pyx_k__readline, sizeof(__pyx_k__readline), 0, 0, 1, 1},
  {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
  {&__pyx_n_s__regex, __pyx_k__regex, sizeof(__pyx_k__regex), 0, 0, 1, 1},
  {&__pyx_n_s__sample, __pyx_k__sample, sizeof(__pyx_k__sample), 0, 0, 1, 1},
  {&__pyx_n_s__sample_id, __pyx_k__sample_id, sizeof(__pyx_k__sample_id), 0, 0, 1, 1},
  {&__pyx_n_s__samples, __pyx_k__samples, sizeof(__pyx_k__samples), 0, 0, 1, 1},
  {&__pyx_n_s__scipy, __pyx_k__scipy, sizeof(__pyx_k__scipy), 0, 0, 1, 1},
  {&__pyx_n_s__search, __pyx_k__search, sizeof(__pyx_k__search), 0, 0, 1, 1},
  {&__pyx_n_s__searchsorted, __pyx_k__searchsorted, sizeof(__pyx_k__searchsorted), 0, 0, 1, 1},
  {&__pyx_n_s__segment_list, __pyx_k__segment_list, sizeof(__pyx_k__segment_list), 0, 0, 1, 1},
  {&__pyx_n_s__segment_lists, __pyx_k__segment_lists, sizeof(__pyx_k__segment_lists), 0, 0, 1, 1},
  {&__pyx_n_s__segmentlist, __pyx_k__segmentlist, sizeof(__pyx_k__segmentlist), 0, 0, 1, 1},
  {&__pyx_n_s__segments, __pyx_k__segments, sizeof(__pyx_k__segments), 0, 0, 1, 1},
  {&__pyx_n_s__segs, __pyx_k__segs, sizeof(__pyx_k__segs), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__shuffle, __pyx_k__shuffle, sizeof(__pyx_k__shuffle), 0, 0, 1, 1},
  {&__pyx_n_s__smoother, __pyx_k__smoother, sizeof(__pyx_k__smoother), 0, 0, 1, 1},
  {&__pyx_n_s__sort, __pyx_k__sort, sizeof(__pyx_k__sort), 0, 0, 1, 1},
  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
  {&__pyx_n_s__split_tracks, __pyx_k__split_tracks, sizeof(__pyx_k__split_tracks), 0, 0, 1, 1},
  {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
  {&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1},
  {&__pyx_n_s__stats, __pyx_k__stats, sizeof(__pyx_k__stats), 0, 0, 1, 1},
  {&__pyx_n_s__std, __pyx_k__std, sizeof(__pyx_k__std), 0, 0, 1, 1},
  {&__pyx_n_s__stddev, __pyx_k__stddev, sizeof(__pyx_k__stddev), 0, 0, 1, 1},
  {&__pyx_n_s__storey, __pyx_k__storey, sizeof(__pyx_k__storey), 0, 0, 1, 1},
  {&__pyx_n_s__sum, __pyx_k__sum, sizeof(__pyx_k__sum), 0, 0, 1, 1},
  {&__pyx_n_s__temp_annos, __pyx_k__temp_annos, sizeof(__pyx_k__temp_annos), 0, 0, 1, 1},
  {&__pyx_n_s__temp_annotations, __pyx_k__temp_annotations, sizeof(__pyx_k__temp_annotations), 0, 0, 1, 1},
  {&__pyx_n_s__temp_segments, __pyx_k__temp_segments, sizeof(__pyx_k__temp_segments), 0, 0, 1, 1},
  {&__pyx_n_s__temp_segs, __pyx_k__temp_segs, sizeof(__pyx_k__temp_segs), 0, 0, 1, 1},
  {&__pyx_n_s__temp_workspace, __pyx_k__temp_workspace, sizeof(__pyx_k__temp_workspace), 0, 0, 1, 1},
  {&__pyx_n_s__toIsochores, __pyx_k__toIsochores, sizeof(__pyx_k__toIsochores), 0, 0, 1, 1},
  {&__pyx_n_s__toKey, __pyx_k__toKey, sizeof(__pyx_k__toKey), 0, 0, 1, 1},
  {&__pyx_n_s__total, __pyx_k__total, sizeof(__pyx_k__total), 0, 0, 1, 1},
  {&__pyx_n_s__track, __pyx_k__track, sizeof(__pyx_k__track), 0, 0, 1, 1},
  {&__pyx_n_s__track_density, __pyx_k__track_density, sizeof(__pyx_k__track_density), 0, 0, 1, 1},
  {&__pyx_n_s__track_nsegments, __pyx_k__track_nsegments, sizeof(__pyx_k__track_nsegments), 0, 0, 1, 1},
  {&__pyx_n_s__track_segments, __pyx_k__track_segments, sizeof(__pyx_k__track_segments), 0, 0, 1, 1},
  {&__pyx_n_s__track_size, __pyx_k__track_size, sizeof(__pyx_k__track_size), 0, 0, 1, 1},
  {&__pyx_n_s__tracks, __pyx_k__tracks, sizeof(__pyx_k__tracks), 0, 0, 1, 1},
  {&__pyx_n_s__truncate, __pyx_k__truncate, sizeof(__pyx_k__truncate), 0, 0, 1, 1},
  {&__pyx_n_s__tsv_iterator, __pyx_k__tsv_iterator, sizeof(__pyx_k__tsv_iterator), 0, 0, 1, 1},
  {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
  {&__pyx_n_s__unreduce, __pyx_k__unreduce, sizeof(__pyx_k__unreduce), 0, 0, 1, 1},
  {&__pyx_n_s__updatePValues, __pyx_k__updatePValues, sizeof(__pyx_k__updatePValues), 0, 0, 1, 1},
  {&__pyx_n_s__updateQValues, __pyx_k__updateQValues, sizeof(__pyx_k__updateQValues), 0, 0, 1, 1},
  {&__pyx_n_s__v, __pyx_k__v, sizeof(__pyx_k__v), 0, 0, 1, 1},
  {&__pyx_n_s__val, __pyx_k__val, sizeof(__pyx_k__val), 0, 0, 1, 1},
  {&__pyx_n_s__vals, __pyx_k__vals, sizeof(__pyx_k__vals), 0, 0, 1, 1},
  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
  {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1},
  {&__pyx_n_s__vlambda, __pyx_k__vlambda, sizeof(__pyx_k__vlambda), 0, 0, 1, 1},
  {&__pyx_n_s__warn, __pyx_k__warn, sizeof(__pyx_k__warn), 0, 0, 1, 1},
  {&__pyx_n_s__workspace, __pyx_k__workspace, sizeof(__pyx_k__workspace), 0, 0, 1, 1},
  {&__pyx_n_s__workspace_generator, __pyx_k__workspace_generator, sizeof(__pyx_k__workspace_generator), 0, 0, 1, 1},
  {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {&__pyx_n_s__z, __pyx_k__z, sizeof(__pyx_k__z), 0, 0, 1, 1},
  {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1},
  {&__pyx_n_s__zip, __pyx_k__zip, sizeof(__pyx_k__zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_property = __Pyx_GetName(__pyx_b, __pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION >= 3
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_sum = __Pyx_GetName(__pyx_b, __pyx_n_s__sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ImportError = __Pyx_GetName(__pyx_b, __pyx_n_s__ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_zip = __Pyx_GetName(__pyx_b, __pyx_n_s__zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "GatEngine.pyx":346
 *         # - creating a sample random doubles once, see numpy.random_integers?
 *         # - avoiding the binary search?
 *         r = numpy.random.random_sample( 1 )[0]             # <<<<<<<<<<<<<<
 *         ip = numpy.searchsorted( self.cdf, r )
 *         base = ip*bucket_size
 */
  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_8);
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));

  /* "GatEngine.pyx":582
 *                 unintersected_segments.trim_ends( start,
 *                                                   -true_remaining,
 *                                                   numpy.random.randint( 0,2) )             # <<<<<<<<<<<<<<
 * 
 *                 # trimming might remove residues outside the workspace
 */
  __pyx_k_tuple_14 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_14);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 1, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));

  /* "GatEngine.pyx":1048
 * 
 *             start = ws.getRandomPosition()
 *             if numpy.random.randint( 0,2 ):             # <<<<<<<<<<<<<<
 *                 end = start + length
 *             else:
 */
  __pyx_k_tuple_18 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_18);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_k_tuple_18, 1, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));

  /* "GatEngine.pyx":1598
 *     l = len(samples)
 *     if l < 1:
 *         raise ValueError( "not enough samples - no stats in makeEnrichmentStatistics" )             # <<<<<<<<<<<<<<
 * 
 *     stats = <EnrichmentStatistics*>malloc( sizeof(EnrichmentStatistics) )
 */
  __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_22);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));

  /* "GatEngine.pyx":1661
 *             stats.pvalue = getTwoSidedPValue( stats, stats.observed / reference.fold )
 *         else:
 *             raise ValueError( "0 fold change not applicable" )             # <<<<<<<<<<<<<<
 * 
 *         # this is analogous to shifting the excepted value.
 */
  __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_24);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
  PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));

  /* "GatEngine.pyx":1889
 *             logfold = "-inf"
 * 
 *         def _toFold( a, b ):             # <<<<<<<<<<<<<<
 *             if b > 0: return self.format_fold % (100.0 * float(a) / b )
 *             else: return "na"
 */
  __pyx_k_tuple_30 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_30);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a));
  PyTuple_SET_ITEM(__pyx_k_tuple_30, 0, ((PyObject *)__pyx_n_s__a));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
  PyTuple_SET_ITEM(__pyx_k_tuple_30, 1, ((PyObject *)__pyx_n_s__b));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_30));
  __pyx_k_codeobj_31 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s___toFold, 1889, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1893
 *             else: return "na"
 * 
 *         def _toDensity( a, b ):             # <<<<<<<<<<<<<<
 *             if b > 0: return self.format_density % (100.0 * float(a) / b )
 *             else: return "na"
 */
  __pyx_k_tuple_33 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_33);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__a));
  PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, ((PyObject *)__pyx_n_s__a));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__a));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
  PyTuple_SET_ITEM(__pyx_k_tuple_33, 1, ((PyObject *)__pyx_n_s__b));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33));
  __pyx_k_codeobj_34 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s___toDensity, 1893, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1936
 *             pvalue = 1.0 - scipy.stats.norm.cdf( absval, 0, r.stddev )
 *         else:
 *             raise ImportError( "scipy required" )             # <<<<<<<<<<<<<<
 *     return pvalue
 * 
 */
  __pyx_k_tuple_36 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_36);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
  PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_kp_s_35));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36));

  /* "GatEngine.pyx":2067
 *         self.expansion = expansion
 *         if self.extension == self.expansion == None:
 *             raise ValueError( "need to specify either expansion or extension" )             # <<<<<<<<<<<<<<
 * 
 *     def __call__( self, segments, annotations, workspace ):
 */
  __pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_40);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
  PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_kp_s_39));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));

  /* "GatEngine.pyx":2260
 *         if i < 0: i += self.nfields
 *         if i >= self.nfields or i < 0:
 *             raise IndexError( "list index out of range" )             # <<<<<<<<<<<<<<
 *         return self.fields[i]
 * 
 */
  __pyx_k_tuple_46 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_46);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_45));
  PyTuple_SET_ITEM(__pyx_k_tuple_46, 0, ((PyObject *)__pyx_kp_s_45));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_45));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46));

  /* "GatEngine.pyx":2317
 *     '''bed track information.'''
 *     def __init__(self, line ):
 *         r= re.compile('([^\s=]+) *= *("[^"]*"|[^ ]*)')             # <<<<<<<<<<<<<<
 * 
 *         self._d = {}
 */
  __pyx_k_tuple_48 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_48);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
  PyTuple_SET_ITEM(__pyx_k_tuple_48, 0, ((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48));

  /* "GatEngine.pyx":2403
 * 
 *     def preparse(self, line ):
 *         if line.startswith("track"):             # <<<<<<<<<<<<<<
 *             self.track = Track( line )
 *             return False
 */
  __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_51);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));

  /* "GatEngine.pyx":2506
 *             return "/" + str(os.getpid()) + "_" + self.name
 *         else:
 *             if key.startswith("/"): key = key[1:]             # <<<<<<<<<<<<<<
 *             return "/" + str(os.getpid()) + "_" + key
 * 
 */
  __pyx_k_tuple_58 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_58);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_57));
  PyTuple_SET_ITEM(__pyx_k_tuple_58, 0, ((PyObject *)__pyx_kp_s_57));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_57));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58));

  /* "GatEngine.pyx":2521
 *         cdef int fd
 *         filename = self._getSharedMemoryName( filename )
 *         assert filename.startswith("/")             # <<<<<<<<<<<<<<
 *         fd = shm_open( filename,
 *                        O_CREAT | O_RDWR,
 */
  __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_60);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_57));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_kp_s_57));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_57));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));

  /* "GatEngine.pyx":2547
 * 
 *         if mm == MAP_FAILED:
 *             raise ValueError("could not create memory mapped file" )             # <<<<<<<<<<<<<<
 * 
 *         # copy all segment lists to shared memory
 */
  __pyx_k_tuple_64 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_64);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_63));
  PyTuple_SET_ITEM(__pyx_k_tuple_64, 0, ((PyObject *)__pyx_kp_s_63));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_63));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64));

  /* "GatEngine.pyx":2767
 *         for isochore, segmentlist in self.intervals.items():
 *             if "." in isochore:
 *                 contig, iso = isochore.split(".")             # <<<<<<<<<<<<<<
 *                 new[contig].extend( segmentlist )
 *                 normalize = True
 */
  __pyx_k_tuple_76 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_76);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_75));
  PyTuple_SET_ITEM(__pyx_k_tuple_76, 0, ((PyObject *)__pyx_kp_s_75));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_75));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_76));

  /* "GatEngine.pyx":2776
 *             # merge adjacent intervals (and normalize)
 *             for x in new.values():
 *                 x.merge( 0 )             # <<<<<<<<<<<<<<
 * 
 *         self.intervals = new
 */
  __pyx_k_tuple_77 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_77);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77));

  /* "GatEngine.pyx":2855
 *         '''output segment statistics.'''
 * 
 *         outfile.write( "section\ttrack\tcontig\tnsegments\tlength\n" )             # <<<<<<<<<<<<<<
 * 
 *         cdef Position total_length = 0
 */
  __pyx_k_tuple_86 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_86);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_85));
  PyTuple_SET_ITEM(__pyx_k_tuple_86, 0, ((PyObject *)__pyx_kp_s_85));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_85));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_86));

  /* "GatEngine.pyx":3016
 *     def outputOverlapStats( self, outfile, other ):
 * 
 *         outfile.write( "section\ttrack\tcontig\toverlap\tlength\tdensity\n" )             # <<<<<<<<<<<<<<
 * 
 *         for track, vv in self.intervals.iteritems():
 */
  __pyx_k_tuple_93 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_93);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_92));
  PyTuple_SET_ITEM(__pyx_k_tuple_93, 0, ((PyObject *)__pyx_kp_s_92));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_92));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_93));

  /* "GatEngine.pyx":3072
 * 
 *     def load( self, track, sample_id, isochore ):
 *         raise ValueError( "loading called for uncached data" )             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key ):
 */
  __pyx_k_tuple_96 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_96);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_95));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 0, ((PyObject *)__pyx_kp_s_95));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_95));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_96));

  /* "numpy.pxd":215
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
  __pyx_k_tuple_104 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_104)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_104);
  __Pyx_INCREF(((PyObject *)__pyx_kp_u_103));
  PyTuple_SET_ITEM(__pyx_k_tuple_104, 0, ((PyObject *)__pyx_kp_u_103));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_103));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_104));

  /* "numpy.pxd":219
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
  __pyx_k_tuple_106 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_106)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_106);
  __Pyx_INCREF(((PyObject *)__pyx_kp_u_105));
  PyTuple_SET_ITEM(__pyx_k_tuple_106, 0, ((PyObject *)__pyx_kp_u_105));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_105));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_106));

  /* "numpy.pxd":257
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
  __pyx_k_tuple_108 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_108)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_108);
  __Pyx_INCREF(((PyObject *)__pyx_kp_u_107));
  PyTuple_SET_ITEM(__pyx_k_tuple_108, 0, ((PyObject *)__pyx_kp_u_107));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_107));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_108));

  /* "numpy.pxd":799
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
  __pyx_k_tuple_111 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_111)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_111);
  __Pyx_INCREF(((PyObject *)__pyx_kp_u_110));
  PyTuple_SET_ITEM(__pyx_k_tuple_111, 0, ((PyObject *)__pyx_kp_u_110));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_110));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_111));

  /* "numpy.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
  __pyx_k_tuple_112 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_112)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_112);
  __Pyx_INCREF(((PyObject *)__pyx_kp_u_107));
  PyTuple_SET_ITEM(__pyx_k_tuple_112, 0, ((PyObject *)__pyx_kp_u_107));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_107));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_112));

  /* "numpy.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
  __pyx_k_tuple_114 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_114)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_114);
  __Pyx_INCREF(((PyObject *)__pyx_kp_u_113));
  PyTuple_SET_ITEM(__pyx_k_tuple_114, 0, ((PyObject *)__pyx_kp_u_113));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_113));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_114));

  /* "GatEngine.pyx":610
 *         return intersected_segments
 * 
 * def buildSamplerAnnotator( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )
 */
  __pyx_k_tuple_120 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_120)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_120);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_120, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_120, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_120));
  __pyx_k_codeobj_121 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s_10, 610, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_121)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":702
 *         return sample
 * 
 * def buildSamplerSegments( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )
 */
  __pyx_k_tuple_122 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_122)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_122);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_122, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_122));
  __pyx_k_codeobj_123 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_122, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s_15, 702, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_123)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":835
 *         return sample
 * 
 * def buildSamplerBruteForce( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerBruteForce( *args )
 */
  __pyx_k_tuple_124 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_124)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_124);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_124));
  __pyx_k_codeobj_125 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_124, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s_16, 835, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_125)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":955
 *         return sample
 * 
 * def buildSamplerUniform( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerUniform object.'''
 *     return SamplerUniform( *args )
 */
  __pyx_k_tuple_126 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_126)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_126);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_126));
  __pyx_k_codeobj_127 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__buildSamplerUniform, 955, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1074
 *         return sample
 * 
 * def buildSamplerShift( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return SamplerShift( *args )
 */
  __pyx_k_tuple_128 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_128);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_128, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_128, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_128));
  __pyx_k_codeobj_129 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_128, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__buildSamplerShift, 1074, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_129)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1454
 * 
 * @cython.boundscheck(False)
 * def getNPTwoSidedPValueFast( numpy.ndarray[DTYPE_FLOAT_t, ndim=1] ar,             # <<<<<<<<<<<<<<
 *                            double val,
 *                            double mean ):
 */
  __pyx_k_tuple_136 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_136)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_136);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ar));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 0, ((PyObject *)__pyx_n_s__ar));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ar));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__val));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 1, ((PyObject *)__pyx_n_s__val));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__val));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mean));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 2, ((PyObject *)__pyx_n_s__mean));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mean));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__l));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 3, ((PyObject *)__pyx_n_s__l));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 4, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__min_pval));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 5, ((PyObject *)__pyx_n_s__min_pval));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__min_pval));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pval));
  PyTuple_SET_ITEM(__pyx_k_tuple_136, 6, ((PyObject *)__pyx_n_s__pval));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pval));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_136));
  __pyx_k_codeobj_137 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_136, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s_138, 1454, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_137)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1926
 * ############################################################
 * ############################################################
 * def getNormedPValue( value, r ):             # <<<<<<<<<<<<<<
 *     '''return pvalue assuming that samples are normal distributed.'''
 *     absval = abs(value - r.expected)
 */
  __pyx_k_tuple_146 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_146)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_146);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__value));
  PyTuple_SET_ITEM(__pyx_k_tuple_146, 0, ((PyObject *)__pyx_n_s__value));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__value));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
  PyTuple_SET_ITEM(__pyx_k_tuple_146, 1, ((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__absval));
  PyTuple_SET_ITEM(__pyx_k_tuple_146, 2, ((PyObject *)__pyx_n_s__absval));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__absval));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pvalue));
  PyTuple_SET_ITEM(__pyx_k_tuple_146, 3, ((PyObject *)__pyx_n_s__pvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_146));
  __pyx_k_codeobj_147 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_146, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__getNormedPValue, 1926, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_147)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1942
 * ############################################################
 * ############################################################
 * def getEmpiricalPValue( value, r ):             # <<<<<<<<<<<<<<
 *     return r.getEmpiricalPValue( value )
 * 
 */
  __pyx_k_tuple_148 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_148)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_148);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__value));
  PyTuple_SET_ITEM(__pyx_k_tuple_148, 0, ((PyObject *)__pyx_n_s__value));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__value));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
  PyTuple_SET_ITEM(__pyx_k_tuple_148, 1, ((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_148));
  __pyx_k_codeobj_149 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_148, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__getEmpiricalPValue, 1942, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_149)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1948
 * ############################################################
 * ############################################################
 * def updatePValues( annotator_results, method = "empirical" ):             # <<<<<<<<<<<<<<
 *     '''update pvalues.
 * 
 */
  __pyx_k_tuple_150 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_150)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_150);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotator_results));
  PyTuple_SET_ITEM(__pyx_k_tuple_150, 0, ((PyObject *)__pyx_n_s__annotator_results));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotator_results));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__method));
  PyTuple_SET_ITEM(__pyx_k_tuple_150, 1, ((PyObject *)__pyx_n_s__method));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__method));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__methodf));
  PyTuple_SET_ITEM(__pyx_k_tuple_150, 2, ((PyObject *)__pyx_n_s__methodf));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__methodf));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
  PyTuple_SET_ITEM(__pyx_k_tuple_150, 3, ((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_150));
  __pyx_k_codeobj_151 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_150, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__updatePValues, 1948, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_151)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1972
 * ############################################################
 * ############################################################
 * def getQValues( pvalues, method = "storey", **kwargs ):             # <<<<<<<<<<<<<<
 *     '''return a list of qvalues for a list of pvalues.'''
 * 
 */
  __pyx_k_tuple_152 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_152)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_152);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pvalues));
  PyTuple_SET_ITEM(__pyx_k_tuple_152, 0, ((PyObject *)__pyx_n_s__pvalues));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pvalues));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__method));
  PyTuple_SET_ITEM(__pyx_k_tuple_152, 1, ((PyObject *)__pyx_n_s__method));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__method));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__kwargs));
  PyTuple_SET_ITEM(__pyx_k_tuple_152, 2, ((PyObject *)__pyx_n_s__kwargs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__kwargs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__kwargs));
  PyTuple_SET_ITEM(__pyx_k_tuple_152, 3, ((PyObject *)__pyx_n_s__kwargs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__kwargs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fdr));
  PyTuple_SET_ITEM(__pyx_k_tuple_152, 4, ((PyObject *)__pyx_n_s__fdr));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fdr));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__msg));
  PyTuple_SET_ITEM(__pyx_k_tuple_152, 5, ((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_152));
  __pyx_k_codeobj_153 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_152, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__getQValues, 1972, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_153)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":1991
 * ############################################################
 * ############################################################
 * def updateQValues( annotator_results, method = "storey", **kwargs ):             # <<<<<<<<<<<<<<
 *     '''update qvalues in annotator results
 * 
 */
  __pyx_k_tuple_154 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_154)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_154);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotator_results));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 0, ((PyObject *)__pyx_n_s__annotator_results));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotator_results));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__method));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 1, ((PyObject *)__pyx_n_s__method));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__method));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__kwargs));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 2, ((PyObject *)__pyx_n_s__kwargs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__kwargs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__kwargs));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 3, ((PyObject *)__pyx_n_s__kwargs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__kwargs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pvalues));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 4, ((PyObject *)__pyx_n_s__pvalues));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pvalues));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 5, ((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qvalue));
  PyTuple_SET_ITEM(__pyx_k_tuple_154, 6, ((PyObject *)__pyx_n_s__qvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_154));
  __pyx_k_codeobj_155 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_154, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__updateQValues, 1991, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_155)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2015
 *     is_conditional = False
 * 
 *     def __call__(self, segments, annotations, workspace):             # <<<<<<<<<<<<<<
 *         return segments, annotations, workspace
 * 
 */
  __pyx_k_tuple_156 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_156)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_156);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_156, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_156, 1, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_156, 2, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_156, 3, ((PyObject *)__pyx_n_s__workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_156));
  __pyx_k_codeobj_157 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_156, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____call__, 2015, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_157)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2018
 *         return segments, annotations, workspace
 * 
 *     def filter( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 *         '''restrict annotations and segments to workspace.
 * 
 */
  __pyx_k_tuple_158 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_158)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_158);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_158, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_158, 1, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_158, 2, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_158, 3, ((PyObject *)__pyx_n_s__workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__workspace));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_158, 4, ((PyObject *)__pyx_n_s__temp_annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_annotations));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_158, 5, ((PyObject *)__pyx_n_s__temp_segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_158));
  __pyx_k_codeobj_159 = (PyObject*)__Pyx_PyCode_New(4, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_158, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__filter, 2018, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_159)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2049
 *     is_conditional = True
 * 
 *     def __call__( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 * 
 *         # restrict workspace to those segments that contain both annotations and segments
 */
  __pyx_k_tuple_162 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_162)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_162);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 1, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 2, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 3, ((PyObject *)__pyx_n_s__workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__workspace));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 4, ((PyObject *)__pyx_n_s__temp_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_162));
  __pyx_k_codeobj_163 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_162, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____call__, 2049, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_163)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2063
 *     is_conditional = True
 * 
 *     def __init__( self, extension = None, expansion = None ):             # <<<<<<<<<<<<<<
 *         self.extension = extension
 *         self.expansion = expansion
 */
  __pyx_k_tuple_166 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_166)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_166);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_166, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__extension));
  PyTuple_SET_ITEM(__pyx_k_tuple_166, 1, ((PyObject *)__pyx_n_s__extension));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__extension));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__expansion));
  PyTuple_SET_ITEM(__pyx_k_tuple_166, 2, ((PyObject *)__pyx_n_s__expansion));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__expansion));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_166));
  __pyx_k_codeobj_167 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_166, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____init__, 2063, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_167)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_tuple_168 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_168)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_168);
  __Pyx_INCREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_k_tuple_168, 0, ((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_k_tuple_168, 1, ((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_168));

  /* "GatEngine.pyx":2069
 *             raise ValueError( "need to specify either expansion or extension" )
 * 
 *     def __call__( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 * 
 *         # build workspace from annotations
 */
  __pyx_k_tuple_169 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_169)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_169);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 1, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 2, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 3, ((PyObject *)__pyx_n_s__workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__workspace));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 4, ((PyObject *)__pyx_n_s__temp_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_169));
  __pyx_k_codeobj_170 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_169, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____call__, 2069, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_170)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2089
 *     workspace is derived from the locations of the annotations.
 *     '''
 *     def getCenter( self, segments, annotations):             # <<<<<<<<<<<<<<
 *         return annotations
 * 
 */
  __pyx_k_tuple_173 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_173)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_173);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 1, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 2, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_173));
  __pyx_k_codeobj_174 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_173, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__getCenter, 2089, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_174)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2099
 *     # workspace needs to be computed on a per-segment basis
 *     is_conditional = False
 *     def getCenter( self, segments, annotations):             # <<<<<<<<<<<<<<
 *         return segments
 * 
 */
  __pyx_k_tuple_177 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_177)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_177);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_177, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_177, 1, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_177, 2, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_177));
  __pyx_k_codeobj_178 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_177, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__getCenter, 2099, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_178)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2107
 * ## compute counts
 * ############################################################
 * def _append( counts, x,y,z): counts[y].append(z)             # <<<<<<<<<<<<<<
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )
 * def _defdictfloat(): return collections.defaultdict(float)
 */
  __pyx_k_tuple_181 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_181)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_181);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__counts));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 0, ((PyObject *)__pyx_n_s__counts));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__counts));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 1, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__y));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 2, ((PyObject *)__pyx_n_s__y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__z));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 3, ((PyObject *)__pyx_n_s__z));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__z));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_181));
  __pyx_k_codeobj_182 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_181, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s___append, 2107, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_182)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2108
 * ############################################################
 * def _append( counts, x,y,z): counts[y].append(z)
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )             # <<<<<<<<<<<<<<
 * def _defdictfloat(): return collections.defaultdict(float)
 * 
 */
  __pyx_k_tuple_183 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_183)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_183);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__counts));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 0, ((PyObject *)__pyx_n_s__counts));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__counts));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 1, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__y));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 2, ((PyObject *)__pyx_n_s__y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__z));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 3, ((PyObject *)__pyx_n_s__z));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__z));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_183));
  __pyx_k_codeobj_184 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_183, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s___set, 2108, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_184)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2109
 * def _append( counts, x,y,z): counts[y].append(z)
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )
 * def _defdictfloat(): return collections.defaultdict(float)             # <<<<<<<<<<<<<<
 * 
 * def computeCounts( counter,
 */
  __pyx_k_codeobj_185 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s___defdictfloat, 2109, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_185)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2111
 * def _defdictfloat(): return collections.defaultdict(float)
 * 
 * def computeCounts( counter,             # <<<<<<<<<<<<<<
 *                    aggregator,
 *                    segments,
 */
  __pyx_k_tuple_186 = PyTuple_New(19); if (unlikely(!__pyx_k_tuple_186)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_186);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__counter));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 0, ((PyObject *)__pyx_n_s__counter));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__counter));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__aggregator));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 1, ((PyObject *)__pyx_n_s__aggregator));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__aggregator));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segments));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 2, ((PyObject *)__pyx_n_s__segments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotations));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 3, ((PyObject *)__pyx_n_s__annotations));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotations));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 4, ((PyObject *)__pyx_n_s__workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__workspace));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__workspace_generator));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 5, ((PyObject *)__pyx_n_s__workspace_generator));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__workspace_generator));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__append));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 6, ((PyObject *)__pyx_n_s__append));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__append));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__counts));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 7, ((PyObject *)__pyx_n_s__counts));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__counts));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__f));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 8, ((PyObject *)__pyx_n_s__f));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__f));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__isochores));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 9, ((PyObject *)__pyx_n_s__isochores));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__isochores));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 10, ((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segs));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 11, ((PyObject *)__pyx_n_s__segs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotation));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 12, ((PyObject *)__pyx_n_s__annotation));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotation));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annos));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 13, ((PyObject *)__pyx_n_s__annos));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annos));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_segs));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 14, ((PyObject *)__pyx_n_s__temp_segs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_segs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_annos));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 15, ((PyObject *)__pyx_n_s__temp_annos));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_annos));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__temp_workspace));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 16, ((PyObject *)__pyx_n_s__temp_workspace));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__temp_workspace));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__vals));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 17, ((PyObject *)__pyx_n_s__vals));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__vals));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__isochore));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 18, ((PyObject *)__pyx_n_s__isochore));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__isochore));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_186));
  __pyx_k_codeobj_187 = (PyObject*)__Pyx_PyCode_New(7, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_186, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__computeCounts, 2111, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_187)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2316
 * class Track(object):
 *     '''bed track information.'''
 *     def __init__(self, line ):             # <<<<<<<<<<<<<<
 *         r= re.compile('([^\s=]+) *= *("[^"]*"|[^ ]*)')
 * 
 */
  __pyx_k_tuple_188 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_188)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_188);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_188, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__line));
  PyTuple_SET_ITEM(__pyx_k_tuple_188, 1, ((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
  PyTuple_SET_ITEM(__pyx_k_tuple_188, 2, ((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__k));
  PyTuple_SET_ITEM(__pyx_k_tuple_188, 3, ((PyObject *)__pyx_n_s__k));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__k));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__v));
  PyTuple_SET_ITEM(__pyx_k_tuple_188, 4, ((PyObject *)__pyx_n_s__v));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__v));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_188));
  __pyx_k_codeobj_189 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_188, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____init__, 2316, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_189)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2327
 * 
 *         self._line = line[:-1]
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self._line
 * 
 */
  __pyx_k_tuple_190 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_190)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_190);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_190, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_190));
  __pyx_k_codeobj_191 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_190, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____str__, 2327, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_191)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2330
 *         return self._line
 * 
 *     def __getitem__(self, key): return self._d[key]             # <<<<<<<<<<<<<<
 *     def __setitem__(self, key,val): self._d[key] = val
 * 
 */
  __pyx_k_tuple_192 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_192)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_192);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_192, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__key));
  PyTuple_SET_ITEM(__pyx_k_tuple_192, 1, ((PyObject *)__pyx_n_s__key));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__key));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_192));
  __pyx_k_codeobj_193 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_192, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____getitem__, 2330, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_193)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2331
 * 
 *     def __getitem__(self, key): return self._d[key]
 *     def __setitem__(self, key,val): self._d[key] = val             # <<<<<<<<<<<<<<
 * 
 * class tsv_iterator:
 */
  __pyx_k_tuple_194 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_194)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_194);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_194, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__key));
  PyTuple_SET_ITEM(__pyx_k_tuple_194, 1, ((PyObject *)__pyx_n_s__key));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__key));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__val));
  PyTuple_SET_ITEM(__pyx_k_tuple_194, 2, ((PyObject *)__pyx_n_s__val));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__val));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_194));
  __pyx_k_codeobj_195 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_194, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____setitem__, 2331, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_195)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2338
 *     Permits the use of file-like objects for example from the gzip module.
 *     '''
 *     def __init__(self, infile ):             # <<<<<<<<<<<<<<
 * 
 *         self.infile = infile
 */
  __pyx_k_tuple_197 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_197)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_197);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_197, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__infile));
  PyTuple_SET_ITEM(__pyx_k_tuple_197, 1, ((PyObject *)__pyx_n_s__infile));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__infile));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_197));
  __pyx_k_codeobj_198 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_197, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____init__, 2338, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_198)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2342
 *         self.infile = infile
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_k_tuple_199 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_199)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_199);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_199, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_199));
  __pyx_k_codeobj_200 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_199, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____iter__, 2342, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_200)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2345
 *         return self
 * 
 *     def preparse( self, line ):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_k_tuple_201 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_201)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_201);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_201, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__line));
  PyTuple_SET_ITEM(__pyx_k_tuple_201, 1, ((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_201));
  __pyx_k_codeobj_202 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_201, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__preparse, 2345, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_202)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2348
 *         return True
 * 
 *     def create( self):             # <<<<<<<<<<<<<<
 *         return TupleProxy()
 * 
 */
  __pyx_k_tuple_203 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_203)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_203);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_203, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_203));
  __pyx_k_codeobj_204 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_203, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__create, 2348, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_204)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2351
 *         return TupleProxy()
 * 
 *     def next(self):             # <<<<<<<<<<<<<<
 * 
 *         cdef char * b
 */
  __pyx_k_tuple_205 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_205)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_205);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_205, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
  PyTuple_SET_ITEM(__pyx_k_tuple_205, 1, ((PyObject *)__pyx_n_s__b));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
  PyTuple_SET_ITEM(__pyx_k_tuple_205, 2, ((PyObject *)__pyx_n_s__r));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__nbytes));
  PyTuple_SET_ITEM(__pyx_k_tuple_205, 3, ((PyObject *)__pyx_n_s__nbytes));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__nbytes));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track));
  PyTuple_SET_ITEM(__pyx_k_tuple_205, 4, ((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__line));
  PyTuple_SET_ITEM(__pyx_k_tuple_205, 5, ((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_205));
  __pyx_k_codeobj_206 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_205, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__next, 2351, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_206)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2398
 *     Permits the use of file-like objects for example from the gzip module.
 *     '''
 *     def __init__(self, infile ):             # <<<<<<<<<<<<<<
 *         tsv_iterator.__init__(self, infile )
 *         self.track = None
 */
  __pyx_k_tuple_208 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_208)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_208);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_208, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__infile));
  PyTuple_SET_ITEM(__pyx_k_tuple_208, 1, ((PyObject *)__pyx_n_s__infile));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__infile));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_208));
  __pyx_k_codeobj_209 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_208, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s____init__, 2398, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_209)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2402
 *         self.track = None
 * 
 *     def preparse(self, line ):             # <<<<<<<<<<<<<<
 *         if line.startswith("track"):
 *             self.track = Track( line )
 */
  __pyx_k_tuple_210 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_210)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_210);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_210, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__line));
  PyTuple_SET_ITEM(__pyx_k_tuple_210, 1, ((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__line));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_210));
  __pyx_k_codeobj_211 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_210, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__preparse, 2402, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_211)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2408
 *         return True
 * 
 *     def create( self ):             # <<<<<<<<<<<<<<
 *         return BedProxy( self.track )
 * 
 */
  __pyx_k_tuple_212 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_212)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_212);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_212, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_212));
  __pyx_k_codeobj_213 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_212, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__create, 2408, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_213)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2411
 *         return BedProxy( self.track )
 * 
 * def _genie():             # <<<<<<<<<<<<<<
 *     return IntervalCollection(SegmentList)
 * 
 */
  __pyx_k_codeobj_214 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s___genie, 2411, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_214)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2414
 *     return IntervalCollection(SegmentList)
 * 
 * def readFromBed( filenames, allow_multiple = False ):             # <<<<<<<<<<<<<<
 *     '''read Segment Lists from one or more bed files.
 * 
 */
  __pyx_k_tuple_215 = PyTuple_New(12); if (unlikely(!__pyx_k_tuple_215)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_215);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__filenames));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 0, ((PyObject *)__pyx_n_s__filenames));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filenames));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__allow_multiple));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 1, ((PyObject *)__pyx_n_s__allow_multiple));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__allow_multiple));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__l));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 2, ((PyObject *)__pyx_n_s__l));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bed));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 3, ((PyObject *)__pyx_n_s__bed));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bed));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__lineno));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 4, ((PyObject *)__pyx_n_s__lineno));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__lineno));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__segment_lists));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 5, ((PyObject *)__pyx_n_s__segment_lists));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__segment_lists));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__tracks));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 6, ((PyObject *)__pyx_n_s__tracks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tracks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__filename));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 7, ((PyObject *)__pyx_n_s__filename));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__infile));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 8, ((PyObject *)__pyx_n_s__infile));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__infile));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__default_name));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 9, ((PyObject *)__pyx_n_s__default_name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__default_name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 10, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__msg));
  PyTuple_SET_ITEM(__pyx_k_tuple_215, 11, ((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_215));
  __pyx_k_codeobj_216 = (PyObject*)__Pyx_PyCode_New(2, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_215, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s__readFromBed, 2414, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_216)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":2780
 *         self.intervals = new
 * 
 * def buildIntervalDictionary( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )
 */
  __pyx_k_tuple_217 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_217)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_217);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_217, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_217, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_217));
  __pyx_k_codeobj_218 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_217, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s_70, 2780, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_218)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "GatEngine.pyx":3029
 *                          "%f" % (float(overlap) / length)) ) + "\n" )
 * 
 * def buildIntervalCollection( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )
 */
  __pyx_k_tuple_219 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_219)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_219);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_219, 0, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_219, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_219));
  __pyx_k_codeobj_220 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_219, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_32, __pyx_n_s_78, 3029, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_220)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __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;};
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_100000 = PyInt_FromLong(100000); if (unlikely(!__pyx_int_100000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initGatEngine(void); /*proto*/
PyMODINIT_FUNC initGatEngine(void)
#else
PyMODINIT_FUNC PyInit_GatEngine(void); /*proto*/
PyMODINIT_FUNC PyInit_GatEngine(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_GatEngine(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("GatEngine"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "GatEngine")) {
      if (unlikely(PyDict_SetItemString(modules, "GatEngine", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  __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;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_GatEngine) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_ptype_9GatEngine_file = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "file", sizeof(PyFileObject), 0); if (unlikely(!__pyx_ptype_9GatEngine_file)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyType_Ready(&__pyx_type_9GatEngine_IntervalContainer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "IntervalContainer", (PyObject *)&__pyx_type_9GatEngine_IntervalContainer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_IntervalContainer = &__pyx_type_9GatEngine_IntervalContainer;
  __pyx_type_9GatEngine_IntervalDictionary.tp_base = __pyx_ptype_9GatEngine_IntervalContainer;
  if (PyType_Ready(&__pyx_type_9GatEngine_IntervalDictionary) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "IntervalDictionary", (PyObject *)&__pyx_type_9GatEngine_IntervalDictionary) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_IntervalDictionary = &__pyx_type_9GatEngine_IntervalDictionary;
  __pyx_type_9GatEngine_IntervalCollection.tp_base = __pyx_ptype_9GatEngine_IntervalContainer;
  if (PyType_Ready(&__pyx_type_9GatEngine_IntervalCollection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "IntervalCollection", (PyObject *)&__pyx_type_9GatEngine_IntervalCollection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_IntervalCollection = &__pyx_type_9GatEngine_IntervalCollection;
  __pyx_vtabptr_9GatEngine_SegmentListSamplerSlow = &__pyx_vtable_9GatEngine_SegmentListSamplerSlow;
  __pyx_vtable_9GatEngine_SegmentListSamplerSlow.sample = (PyObject *(*)(struct __pyx_obj_9GatEngine_SegmentListSamplerSlow *, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch))__pyx_f_9GatEngine_22SegmentListSamplerSlow_sample;
  if (PyType_Ready(&__pyx_type_9GatEngine_SegmentListSamplerSlow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SegmentListSamplerSlow.tp_dict, __pyx_vtabptr_9GatEngine_SegmentListSamplerSlow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SegmentListSamplerSlow", (PyObject *)&__pyx_type_9GatEngine_SegmentListSamplerSlow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SegmentListSamplerSlow = &__pyx_type_9GatEngine_SegmentListSamplerSlow;
  __pyx_vtabptr_9GatEngine_SegmentListSamplerWithEdgeEffects = &__pyx_vtable_9GatEngine_SegmentListSamplerWithEdgeEffects;
  __pyx_vtable_9GatEngine_SegmentListSamplerWithEdgeEffects.sample = (PyObject *(*)(struct __pyx_obj_9GatEngine_SegmentListSamplerWithEdgeEffects *, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch))__pyx_f_9GatEngine_33SegmentListSamplerWithEdgeEffects_sample;
  if (PyType_Ready(&__pyx_type_9GatEngine_SegmentListSamplerWithEdgeEffects) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SegmentListSamplerWithEdgeEffects.tp_dict, __pyx_vtabptr_9GatEngine_SegmentListSamplerWithEdgeEffects) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SegmentListSamplerWithEdgeEffects", (PyObject *)&__pyx_type_9GatEngine_SegmentListSamplerWithEdgeEffects) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SegmentListSamplerWithEdgeEffects = &__pyx_type_9GatEngine_SegmentListSamplerWithEdgeEffects;
  __pyx_vtabptr_9GatEngine_SegmentListSampler = &__pyx_vtable_9GatEngine_SegmentListSampler;
  __pyx_vtable_9GatEngine_SegmentListSampler.sample = (PyObject *(*)(struct __pyx_obj_9GatEngine_SegmentListSampler *, __pyx_t_14GatSegmentList_Position, int __pyx_skip_dispatch))__pyx_f_9GatEngine_18SegmentListSampler_sample;
  if (PyType_Ready(&__pyx_type_9GatEngine_SegmentListSampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SegmentListSampler.tp_dict, __pyx_vtabptr_9GatEngine_SegmentListSampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SegmentListSampler", (PyObject *)&__pyx_type_9GatEngine_SegmentListSampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SegmentListSampler = &__pyx_type_9GatEngine_SegmentListSampler;
  __pyx_vtabptr_9GatEngine_HistogramSamplerSlow = &__pyx_vtable_9GatEngine_HistogramSamplerSlow;
  __pyx_vtable_9GatEngine_HistogramSamplerSlow.sample = (__pyx_t_14GatSegmentList_Position (*)(struct __pyx_obj_9GatEngine_HistogramSamplerSlow *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_20HistogramSamplerSlow_sample;
  if (PyType_Ready(&__pyx_type_9GatEngine_HistogramSamplerSlow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_HistogramSamplerSlow.tp_dict, __pyx_vtabptr_9GatEngine_HistogramSamplerSlow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "HistogramSamplerSlow", (PyObject *)&__pyx_type_9GatEngine_HistogramSamplerSlow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_HistogramSamplerSlow = &__pyx_type_9GatEngine_HistogramSamplerSlow;
  __pyx_vtabptr_9GatEngine_HistogramSampler = &__pyx_vtable_9GatEngine_HistogramSampler;
  __pyx_vtable_9GatEngine_HistogramSampler.sample = (__pyx_t_14GatSegmentList_Position (*)(struct __pyx_obj_9GatEngine_HistogramSampler *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_16HistogramSampler_sample;
  if (PyType_Ready(&__pyx_type_9GatEngine_HistogramSampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_HistogramSampler.tp_dict, __pyx_vtabptr_9GatEngine_HistogramSampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "HistogramSampler", (PyObject *)&__pyx_type_9GatEngine_HistogramSampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_HistogramSampler = &__pyx_type_9GatEngine_HistogramSampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_Sampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Sampler", (PyObject *)&__pyx_type_9GatEngine_Sampler) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_Sampler = &__pyx_type_9GatEngine_Sampler;
  __pyx_vtabptr_9GatEngine_SamplerAnnotator = &__pyx_vtable_9GatEngine_SamplerAnnotator;
  __pyx_vtable_9GatEngine_SamplerAnnotator.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerAnnotator *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_16SamplerAnnotator_sample;
  __pyx_type_9GatEngine_SamplerAnnotator.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerAnnotator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerAnnotator.tp_dict, __pyx_vtabptr_9GatEngine_SamplerAnnotator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerAnnotator", (PyObject *)&__pyx_type_9GatEngine_SamplerAnnotator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerAnnotator = &__pyx_type_9GatEngine_SamplerAnnotator;
  __pyx_vtabptr_9GatEngine_SamplerSegments = &__pyx_vtable_9GatEngine_SamplerSegments;
  __pyx_vtable_9GatEngine_SamplerSegments.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerSegments *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_15SamplerSegments_sample;
  __pyx_type_9GatEngine_SamplerSegments.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerSegments) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerSegments.tp_dict, __pyx_vtabptr_9GatEngine_SamplerSegments) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerSegments", (PyObject *)&__pyx_type_9GatEngine_SamplerSegments) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerSegments = &__pyx_type_9GatEngine_SamplerSegments;
  __pyx_vtabptr_9GatEngine_SamplerBruteForce = &__pyx_vtable_9GatEngine_SamplerBruteForce;
  __pyx_vtable_9GatEngine_SamplerBruteForce.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerBruteForce *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_17SamplerBruteForce_sample;
  __pyx_type_9GatEngine_SamplerBruteForce.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerBruteForce) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerBruteForce.tp_dict, __pyx_vtabptr_9GatEngine_SamplerBruteForce) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerBruteForce", (PyObject *)&__pyx_type_9GatEngine_SamplerBruteForce) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerBruteForce = &__pyx_type_9GatEngine_SamplerBruteForce;
  __pyx_vtabptr_9GatEngine_SamplerUniform = &__pyx_vtable_9GatEngine_SamplerUniform;
  __pyx_vtable_9GatEngine_SamplerUniform.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerUniform *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_14SamplerUniform_sample;
  __pyx_type_9GatEngine_SamplerUniform.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerUniform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerUniform.tp_dict, __pyx_vtabptr_9GatEngine_SamplerUniform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerUniform", (PyObject *)&__pyx_type_9GatEngine_SamplerUniform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerUniform = &__pyx_type_9GatEngine_SamplerUniform;
  __pyx_vtabptr_9GatEngine_SamplerShift = &__pyx_vtable_9GatEngine_SamplerShift;
  __pyx_vtable_9GatEngine_SamplerShift.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerShift *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_12SamplerShift_sample;
  __pyx_type_9GatEngine_SamplerShift.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerShift) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerShift.tp_dict, __pyx_vtabptr_9GatEngine_SamplerShift) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerShift", (PyObject *)&__pyx_type_9GatEngine_SamplerShift) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerShift = &__pyx_type_9GatEngine_SamplerShift;
  __pyx_vtabptr_9GatEngine_SamplerLocalPermutation = &__pyx_vtable_9GatEngine_SamplerLocalPermutation;
  __pyx_vtable_9GatEngine_SamplerLocalPermutation.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerLocalPermutation *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_23SamplerLocalPermutation_sample;
  __pyx_type_9GatEngine_SamplerLocalPermutation.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerLocalPermutation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerLocalPermutation.tp_dict, __pyx_vtabptr_9GatEngine_SamplerLocalPermutation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerLocalPermutation", (PyObject *)&__pyx_type_9GatEngine_SamplerLocalPermutation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerLocalPermutation = &__pyx_type_9GatEngine_SamplerLocalPermutation;
  __pyx_vtabptr_9GatEngine_SamplerGlobalPermutation = &__pyx_vtable_9GatEngine_SamplerGlobalPermutation;
  __pyx_vtable_9GatEngine_SamplerGlobalPermutation.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerGlobalPermutation *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_24SamplerGlobalPermutation_sample;
  __pyx_type_9GatEngine_SamplerGlobalPermutation.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerGlobalPermutation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerGlobalPermutation.tp_dict, __pyx_vtabptr_9GatEngine_SamplerGlobalPermutation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerGlobalPermutation", (PyObject *)&__pyx_type_9GatEngine_SamplerGlobalPermutation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerGlobalPermutation = &__pyx_type_9GatEngine_SamplerGlobalPermutation;
  __pyx_vtabptr_9GatEngine_SamplerDummy = &__pyx_vtable_9GatEngine_SamplerDummy;
  __pyx_vtable_9GatEngine_SamplerDummy.sample = (struct __pyx_obj_14GatSegmentList_SegmentList *(*)(struct __pyx_obj_9GatEngine_SamplerDummy *, struct __pyx_obj_14GatSegmentList_SegmentList *, struct __pyx_obj_14GatSegmentList_SegmentList *, int __pyx_skip_dispatch))__pyx_f_9GatEngine_12SamplerDummy_sample;
  __pyx_type_9GatEngine_SamplerDummy.tp_base = __pyx_ptype_9GatEngine_Sampler;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplerDummy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_SamplerDummy, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_12SamplerDummy___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_12SamplerDummy___init__.doc = __pyx_doc_9GatEngine_12SamplerDummy___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_12SamplerDummy___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_SamplerDummy.tp_dict, __pyx_vtabptr_9GatEngine_SamplerDummy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "SamplerDummy", (PyObject *)&__pyx_type_9GatEngine_SamplerDummy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplerDummy = &__pyx_type_9GatEngine_SamplerDummy;
  if (PyType_Ready(&__pyx_type_9GatEngine_Counter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Counter", (PyObject *)&__pyx_type_9GatEngine_Counter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_Counter = &__pyx_type_9GatEngine_Counter;
  __pyx_type_9GatEngine_CounterNucleotideOverlap.tp_base = __pyx_ptype_9GatEngine_Counter;
  if (PyType_Ready(&__pyx_type_9GatEngine_CounterNucleotideOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_CounterNucleotideOverlap, "__call__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_24CounterNucleotideOverlap___call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_24CounterNucleotideOverlap___call__.doc = __pyx_doc_9GatEngine_24CounterNucleotideOverlap___call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_24CounterNucleotideOverlap___call__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "CounterNucleotideOverlap", (PyObject *)&__pyx_type_9GatEngine_CounterNucleotideOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_CounterNucleotideOverlap = &__pyx_type_9GatEngine_CounterNucleotideOverlap;
  __pyx_type_9GatEngine_CounterNucleotideDensity.tp_base = __pyx_ptype_9GatEngine_Counter;
  if (PyType_Ready(&__pyx_type_9GatEngine_CounterNucleotideDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_CounterNucleotideDensity, "__call__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_24CounterNucleotideDensity___call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_24CounterNucleotideDensity___call__.doc = __pyx_doc_9GatEngine_24CounterNucleotideDensity___call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_24CounterNucleotideDensity___call__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "CounterNucleotideDensity", (PyObject *)&__pyx_type_9GatEngine_CounterNucleotideDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_CounterNucleotideDensity = &__pyx_type_9GatEngine_CounterNucleotideDensity;
  __pyx_type_9GatEngine_CounterSegmentOverlap.tp_base = __pyx_ptype_9GatEngine_Counter;
  if (PyType_Ready(&__pyx_type_9GatEngine_CounterSegmentOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_CounterSegmentOverlap, "__call__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_21CounterSegmentOverlap___call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_21CounterSegmentOverlap___call__.doc = __pyx_doc_9GatEngine_21CounterSegmentOverlap___call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_21CounterSegmentOverlap___call__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "CounterSegmentOverlap", (PyObject *)&__pyx_type_9GatEngine_CounterSegmentOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_CounterSegmentOverlap = &__pyx_type_9GatEngine_CounterSegmentOverlap;
  __pyx_type_9GatEngine_CounterSegmentMidpointOverlap.tp_base = __pyx_ptype_9GatEngine_Counter;
  if (PyType_Ready(&__pyx_type_9GatEngine_CounterSegmentMidpointOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_CounterSegmentMidpointOverlap, "__call__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_29CounterSegmentMidpointOverlap___call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_29CounterSegmentMidpointOverlap___call__.doc = __pyx_doc_9GatEngine_29CounterSegmentMidpointOverlap___call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_29CounterSegmentMidpointOverlap___call__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "CounterSegmentMidpointOverlap", (PyObject *)&__pyx_type_9GatEngine_CounterSegmentMidpointOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_CounterSegmentMidpointOverlap = &__pyx_type_9GatEngine_CounterSegmentMidpointOverlap;
  __pyx_type_9GatEngine_CounterAnnotationOverlap.tp_base = __pyx_ptype_9GatEngine_Counter;
  if (PyType_Ready(&__pyx_type_9GatEngine_CounterAnnotationOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_CounterAnnotationOverlap, "__call__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_24CounterAnnotationOverlap___call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_24CounterAnnotationOverlap___call__.doc = __pyx_doc_9GatEngine_24CounterAnnotationOverlap___call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_24CounterAnnotationOverlap___call__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "CounterAnnotationOverlap", (PyObject *)&__pyx_type_9GatEngine_CounterAnnotationOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_CounterAnnotationOverlap = &__pyx_type_9GatEngine_CounterAnnotationOverlap;
  __pyx_type_9GatEngine_CounterAnnotationMidpointOverlap.tp_base = __pyx_ptype_9GatEngine_Counter;
  if (PyType_Ready(&__pyx_type_9GatEngine_CounterAnnotationMidpointOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_CounterAnnotationMidpointOverlap, "__call__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_32CounterAnnotationMidpointOverlap___call__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_32CounterAnnotationMidpointOverlap___call__.doc = __pyx_doc_9GatEngine_32CounterAnnotationMidpointOverlap___call__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_32CounterAnnotationMidpointOverlap___call__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "CounterAnnotationMidpointOverlap", (PyObject *)&__pyx_type_9GatEngine_CounterAnnotationMidpointOverlap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_CounterAnnotationMidpointOverlap = &__pyx_type_9GatEngine_CounterAnnotationMidpointOverlap;
  if (PyType_Ready(&__pyx_type_9GatEngine_AnnotatorResult) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "AnnotatorResult", (PyObject *)&__pyx_type_9GatEngine_AnnotatorResult) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_AnnotatorResult = &__pyx_type_9GatEngine_AnnotatorResult;
  __pyx_type_9GatEngine_AnnotatorResultExtended.tp_base = __pyx_ptype_9GatEngine_AnnotatorResult;
  if (PyType_Ready(&__pyx_type_9GatEngine_AnnotatorResultExtended) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "AnnotatorResultExtended", (PyObject *)&__pyx_type_9GatEngine_AnnotatorResultExtended) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_AnnotatorResultExtended = &__pyx_type_9GatEngine_AnnotatorResultExtended;
  __pyx_vtabptr_9GatEngine_TupleProxy = &__pyx_vtable_9GatEngine_TupleProxy;
  __pyx_vtable_9GatEngine_TupleProxy.take = (PyObject *(*)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t))__pyx_f_9GatEngine_10TupleProxy_take;
  __pyx_vtable_9GatEngine_TupleProxy.present = (PyObject *(*)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t))__pyx_f_9GatEngine_10TupleProxy_present;
  __pyx_vtable_9GatEngine_TupleProxy.copy = (PyObject *(*)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t))__pyx_f_9GatEngine_10TupleProxy_copy;
  __pyx_vtable_9GatEngine_TupleProxy.update = (PyObject *(*)(struct __pyx_obj_9GatEngine_TupleProxy *, char *, size_t))__pyx_f_9GatEngine_10TupleProxy_update;
  if (PyType_Ready(&__pyx_type_9GatEngine_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_TupleProxy, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_10TupleProxy_10__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_10TupleProxy_10__next__.doc = __pyx_doc_9GatEngine_10TupleProxy_10__next__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_10TupleProxy_10__next__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_TupleProxy.tp_dict, __pyx_vtabptr_9GatEngine_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "TupleProxy", (PyObject *)&__pyx_type_9GatEngine_TupleProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_TupleProxy = &__pyx_type_9GatEngine_TupleProxy;
  __pyx_vtabptr_9GatEngine_BedProxy = &__pyx_vtable_9GatEngine_BedProxy;
  __pyx_vtable_9GatEngine_BedProxy.__pyx_base = *__pyx_vtabptr_9GatEngine_TupleProxy;
  __pyx_type_9GatEngine_BedProxy.tp_base = __pyx_ptype_9GatEngine_TupleProxy;
  if (PyType_Ready(&__pyx_type_9GatEngine_BedProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_9GatEngine_BedProxy.tp_dict, __pyx_vtabptr_9GatEngine_BedProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "BedProxy", (PyObject *)&__pyx_type_9GatEngine_BedProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_BedProxy = &__pyx_type_9GatEngine_BedProxy;
  if (PyType_Ready(&__pyx_type_9GatEngine_Samples) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_Samples, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_7Samples___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_7Samples___init__.doc = __pyx_doc_9GatEngine_7Samples___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_7Samples___init__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_Samples, "__getitem__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_7Samples_8__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_7Samples_8__getitem__.doc = __pyx_doc_9GatEngine_7Samples_8__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_7Samples_8__getitem__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "Samples", (PyObject *)&__pyx_type_9GatEngine_Samples) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_Samples = &__pyx_type_9GatEngine_Samples;
  __pyx_type_9GatEngine_SamplesFile.tp_base = __pyx_ptype_9GatEngine_Samples;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplesFile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_SamplesFile, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_11SamplesFile___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_11SamplesFile___init__.doc = __pyx_doc_9GatEngine_11SamplesFile___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_11SamplesFile___init__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "SamplesFile", (PyObject *)&__pyx_type_9GatEngine_SamplesFile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplesFile = &__pyx_type_9GatEngine_SamplesFile;
  __pyx_type_9GatEngine_SamplesCached.tp_base = __pyx_ptype_9GatEngine_Samples;
  if (PyType_Ready(&__pyx_type_9GatEngine_SamplesCached) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9GatEngine_SamplesCached, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9GatEngine_13SamplesCached___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9GatEngine_13SamplesCached___init__.doc = __pyx_doc_9GatEngine_13SamplesCached___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9GatEngine_13SamplesCached___init__;
    }
  }
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "SamplesCached", (PyObject *)&__pyx_type_9GatEngine_SamplesCached) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine_SamplesCached = &__pyx_type_9GatEngine_SamplesCached;
  if (PyType_Ready(&__pyx_type_9GatEngine___pyx_scope_struct____str__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine___pyx_scope_struct____str__ = &__pyx_type_9GatEngine___pyx_scope_struct____str__;
  if (PyType_Ready(&__pyx_type_9GatEngine___pyx_scope_struct_1_getSegmentLists) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine___pyx_scope_struct_1_getSegmentLists = &__pyx_type_9GatEngine___pyx_scope_struct_1_getSegmentLists;
  if (PyType_Ready(&__pyx_type_9GatEngine___pyx_scope_struct_2_getSegmentLists) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_9GatEngine___pyx_scope_struct_2_getSegmentLists = &__pyx_type_9GatEngine___pyx_scope_struct_2_getSegmentLists;
  /*--- Type import code ---*/
  __pyx_ptype_14GatSegmentList_file = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "file", sizeof(PyFileObject), 0); if (unlikely(!__pyx_ptype_14GatSegmentList_file)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14GatSegmentList_SegmentList = __Pyx_ImportType("GatSegmentList", "SegmentList", sizeof(struct __pyx_obj_14GatSegmentList_SegmentList), 1); if (unlikely(!__pyx_ptype_14GatSegmentList_SegmentList)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_14GatSegmentList_SegmentList = (struct __pyx_vtabstruct_14GatSegmentList_SegmentList*)__Pyx_GetVtable(__pyx_ptype_14GatSegmentList_SegmentList->tp_dict); if (unlikely(!__pyx_vtabptr_14GatSegmentList_SegmentList)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "GatEngine.pyx":4
 * # cython: profile=False
 * 
 * import types, collections, re, os, math, random             # <<<<<<<<<<<<<<
 * 
 * import gat.IOTools as IOTools
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__collections, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__math), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__math, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__random), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__random, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":6
 * import types, collections, re, os, math, random
 * 
 * import gat.IOTools as IOTools             # <<<<<<<<<<<<<<
 * import gat.Experiment as E
 * import gat.Stats
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s_116));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s_116));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_116));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_115), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IOTools, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":7
 * 
 * import gat.IOTools as IOTools
 * import gat.Experiment as E             # <<<<<<<<<<<<<<
 * import gat.Stats
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s_116));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_116));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_116));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_117), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__E, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":8
 * import gat.IOTools as IOTools
 * import gat.Experiment as E
 * import gat.Stats             # <<<<<<<<<<<<<<
 * 
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_118), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":15
 * # import segmentlist
 * cimport GatSegmentList
 * import GatSegmentList             # <<<<<<<<<<<<<<
 * from GatSegmentList cimport SegmentList, PositionDifference, Segment, Position
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__GatSegmentList), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GatSegmentList, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":21
 * ## Numpy import
 * # note both import and cimport are necessary
 * import numpy             # <<<<<<<<<<<<<<
 * cimport numpy
 * DTYPE_INT = numpy.int
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":23
 * import numpy
 * cimport numpy
 * DTYPE_INT = numpy.int             # <<<<<<<<<<<<<<
 * ctypedef numpy.int_t DTYPE_INT_t
 * DTYPE_FLOAT = numpy.float
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__int); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE_INT, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":25
 * DTYPE_INT = numpy.int
 * ctypedef numpy.int_t DTYPE_INT_t
 * DTYPE_FLOAT = numpy.float             # <<<<<<<<<<<<<<
 * ctypedef numpy.float_t DTYPE_FLOAT_t
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__float); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DTYPE_FLOAT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":31
 * ## scipy import
 * ## required for pvalues based on parametric distributions
 * try:             # <<<<<<<<<<<<<<
 *     import scipy
 *     import scipy.stats
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "GatEngine.pyx":32
 * ## required for pvalues based on parametric distributions
 * try:
 *     import scipy             # <<<<<<<<<<<<<<
 *     import scipy.stats
 *     HAS_SCIPY = True
 */
      __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__scipy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__scipy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GatEngine.pyx":33
 * try:
 *     import scipy
 *     import scipy.stats             # <<<<<<<<<<<<<<
 *     HAS_SCIPY = True
 * except:
 */
      __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_119), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__scipy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "GatEngine.pyx":34
 *     import scipy
 *     import scipy.stats
 *     HAS_SCIPY = True             # <<<<<<<<<<<<<<
 * except:
 *     HAS_SCIPY = False
 */
      __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__HAS_SCIPY, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L9_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "GatEngine.pyx":35
 *     import scipy.stats
 *     HAS_SCIPY = True
 * except:             # <<<<<<<<<<<<<<
 *     HAS_SCIPY = False
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("GatEngine", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_6);

      /* "GatEngine.pyx":36
 *     HAS_SCIPY = True
 * except:
 *     HAS_SCIPY = False             # <<<<<<<<<<<<<<
 * 
 * # min/max are not optimized, so declare them as C functions
 */
      __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__HAS_SCIPY, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L3_exception_handled;
    }
    __pyx_L4_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L9_try_end:;
  }

  /* "GatEngine.pyx":610
 *         return intersected_segments
 * 
 * def buildSamplerAnnotator( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_1buildSamplerAnnotator, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_10, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":702
 *         return sample
 * 
 * def buildSamplerSegments( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerAnnotator( *args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_3buildSamplerSegments, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_15, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":835
 *         return sample
 * 
 * def buildSamplerBruteForce( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuild SamplerAnnotator object.'''
 *     return SamplerBruteForce( *args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_5buildSamplerBruteForce, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_16, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":955
 *         return sample
 * 
 * def buildSamplerUniform( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerUniform object.'''
 *     return SamplerUniform( *args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_7buildSamplerUniform, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__buildSamplerUniform, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1074
 *         return sample
 * 
 * def buildSamplerShift( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return SamplerShift( *args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_9buildSamplerShift, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__buildSamplerShift, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1382
 * 
 * cdef class CounterNucleotideOverlap(Counter):
 *     name = "nucleotide-overlap"             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, SegmentList segments, SegmentList annotations, SegmentList workspace = None ):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_CounterNucleotideOverlap->tp_dict, __pyx_n_s__name, ((PyObject *)__pyx_kp_s_130)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_CounterNucleotideOverlap);

  /* "GatEngine.pyx":1389
 * 
 * cdef class CounterNucleotideDensity(Counter):
 *     name = "nucleotide-density"             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, SegmentList segments, SegmentList annotations, SegmentList workspace ):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_CounterNucleotideDensity->tp_dict, __pyx_n_s__name, ((PyObject *)__pyx_kp_s_131)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_CounterNucleotideDensity);

  /* "GatEngine.pyx":1401
 * 
 * cdef class CounterSegmentOverlap(Counter):
 *     name = "segment-overlap"             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, segments, annotations, workspace = None ):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_CounterSegmentOverlap->tp_dict, __pyx_n_s__name, ((PyObject *)__pyx_kp_s_132)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_CounterSegmentOverlap);

  /* "GatEngine.pyx":1408
 * 
 * cdef class CounterSegmentMidpointOverlap(Counter):
 *     name = "segment-midoverlap"             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, segments, annotations, workspace = None ):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_CounterSegmentMidpointOverlap->tp_dict, __pyx_n_s__name, ((PyObject *)__pyx_kp_s_133)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_CounterSegmentMidpointOverlap);

  /* "GatEngine.pyx":1415
 * 
 * cdef class CounterAnnotationOverlap(Counter):
 *     name = "annotation-overlap"             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, segments, annotations, workspace = None ):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_CounterAnnotationOverlap->tp_dict, __pyx_n_s__name, ((PyObject *)__pyx_kp_s_134)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_CounterAnnotationOverlap);

  /* "GatEngine.pyx":1422
 * 
 * cdef class CounterAnnotationMidpointOverlap(Counter):
 *     name = "annotation-midoverlap"             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, segments, annotations, workspace = None ):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_CounterAnnotationMidpointOverlap->tp_dict, __pyx_n_s__name, ((PyObject *)__pyx_kp_s_135)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_CounterAnnotationMidpointOverlap);

  /* "GatEngine.pyx":1454
 * 
 * @cython.boundscheck(False)
 * def getNPTwoSidedPValueFast( numpy.ndarray[DTYPE_FLOAT_t, ndim=1] ar,             # <<<<<<<<<<<<<<
 *                            double val,
 *                            double mean ):
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_13getNPTwoSidedPValueFast, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_138, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1681
 * 
 *     cdef str format_observed
 *     format_expected = "%6.4f"             # <<<<<<<<<<<<<<
 *     format_fold = "%6.4f"
 *     format_pvalue = "%6.4e"
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResult->tp_dict, __pyx_n_s__format_expected, ((PyObject *)__pyx_kp_s_139)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResult);

  /* "GatEngine.pyx":1682
 *     cdef str format_observed
 *     format_expected = "%6.4f"
 *     format_fold = "%6.4f"             # <<<<<<<<<<<<<<
 *     format_pvalue = "%6.4e"
 *     format_counts = "%i"
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResult->tp_dict, __pyx_n_s__format_fold, ((PyObject *)__pyx_kp_s_139)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResult);

  /* "GatEngine.pyx":1683
 *     format_expected = "%6.4f"
 *     format_fold = "%6.4f"
 *     format_pvalue = "%6.4e"             # <<<<<<<<<<<<<<
 *     format_counts = "%i"
 *     format_density = "%6.4e"
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResult->tp_dict, __pyx_n_s__format_pvalue, ((PyObject *)__pyx_kp_s_140)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResult);

  /* "GatEngine.pyx":1684
 *     format_fold = "%6.4f"
 *     format_pvalue = "%6.4e"
 *     format_counts = "%i"             # <<<<<<<<<<<<<<
 *     format_density = "%6.4e"
 * 
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResult->tp_dict, __pyx_n_s__format_counts, ((PyObject *)__pyx_kp_s_26)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResult);

  /* "GatEngine.pyx":1685
 *     format_pvalue = "%6.4e"
 *     format_counts = "%i"
 *     format_density = "%6.4e"             # <<<<<<<<<<<<<<
 * 
 *     headers = ["track",
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResult->tp_dict, __pyx_n_s__format_density, ((PyObject *)__pyx_kp_s_140)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResult);

  /* "GatEngine.pyx":1687
 *     format_density = "%6.4e"
 * 
 *     headers = ["track",             # <<<<<<<<<<<<<<
 *                "annotation",
 *                "observed",
 */
  __pyx_t_6 = PyList_New(11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotation));
  PyList_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__annotation));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotation));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__observed));
  PyList_SET_ITEM(__pyx_t_6, 2, ((PyObject *)__pyx_n_s__observed));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__observed));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__expected));
  PyList_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_n_s__expected));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__expected));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__CI95low));
  PyList_SET_ITEM(__pyx_t_6, 4, ((PyObject *)__pyx_n_s__CI95low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CI95low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__CI95high));
  PyList_SET_ITEM(__pyx_t_6, 5, ((PyObject *)__pyx_n_s__CI95high));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CI95high));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__stddev));
  PyList_SET_ITEM(__pyx_t_6, 6, ((PyObject *)__pyx_n_s__stddev));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__stddev));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fold));
  PyList_SET_ITEM(__pyx_t_6, 7, ((PyObject *)__pyx_n_s__fold));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fold));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__l2fold));
  PyList_SET_ITEM(__pyx_t_6, 8, ((PyObject *)__pyx_n_s__l2fold));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l2fold));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pvalue));
  PyList_SET_ITEM(__pyx_t_6, 9, ((PyObject *)__pyx_n_s__pvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pvalue));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qvalue));
  PyList_SET_ITEM(__pyx_t_6, 10, ((PyObject *)__pyx_n_s__qvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qvalue));
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResult->tp_dict, __pyx_n_s__headers, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResult);

  /* "GatEngine.pyx":1711
 *                   samples,
 *                   reference = None,
 *                   pseudo_count = 1.0 ):             # <<<<<<<<<<<<<<
 *         self.track = track
 *         self.annotation = annotation
 */
  __pyx_t_6 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_25 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":1809
 *     '''container for annotator results.'''
 * 
 *     format_density = "%6.4e"             # <<<<<<<<<<<<<<
 * 
 *     headers = ["track",
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResultExtended->tp_dict, __pyx_n_s__format_density, ((PyObject *)__pyx_kp_s_140)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResultExtended);

  /* "GatEngine.pyx":1811
 *     format_density = "%6.4e"
 * 
 *     headers = ["track",             # <<<<<<<<<<<<<<
 *                "annotation",
 *                "observed",
 */
  __pyx_t_6 = PyList_New(24); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_n_s__track));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotation));
  PyList_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__annotation));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotation));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__observed));
  PyList_SET_ITEM(__pyx_t_6, 2, ((PyObject *)__pyx_n_s__observed));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__observed));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__expected));
  PyList_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_n_s__expected));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__expected));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__CI95low));
  PyList_SET_ITEM(__pyx_t_6, 4, ((PyObject *)__pyx_n_s__CI95low));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CI95low));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__CI95high));
  PyList_SET_ITEM(__pyx_t_6, 5, ((PyObject *)__pyx_n_s__CI95high));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CI95high));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__stddev));
  PyList_SET_ITEM(__pyx_t_6, 6, ((PyObject *)__pyx_n_s__stddev));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__stddev));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fold));
  PyList_SET_ITEM(__pyx_t_6, 7, ((PyObject *)__pyx_n_s__fold));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fold));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__l2fold));
  PyList_SET_ITEM(__pyx_t_6, 8, ((PyObject *)__pyx_n_s__l2fold));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l2fold));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__pvalue));
  PyList_SET_ITEM(__pyx_t_6, 9, ((PyObject *)__pyx_n_s__pvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pvalue));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__qvalue));
  PyList_SET_ITEM(__pyx_t_6, 10, ((PyObject *)__pyx_n_s__qvalue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qvalue));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track_nsegments));
  PyList_SET_ITEM(__pyx_t_6, 11, ((PyObject *)__pyx_n_s__track_nsegments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track_nsegments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track_size));
  PyList_SET_ITEM(__pyx_t_6, 12, ((PyObject *)__pyx_n_s__track_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track_size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__track_density));
  PyList_SET_ITEM(__pyx_t_6, 13, ((PyObject *)__pyx_n_s__track_density));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__track_density));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_141));
  PyList_SET_ITEM(__pyx_t_6, 14, ((PyObject *)__pyx_n_s_141));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_141));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotation_size));
  PyList_SET_ITEM(__pyx_t_6, 15, ((PyObject *)__pyx_n_s__annotation_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotation_size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__annotation_density));
  PyList_SET_ITEM(__pyx_t_6, 16, ((PyObject *)__pyx_n_s__annotation_density));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__annotation_density));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__overlap_nsegments));
  PyList_SET_ITEM(__pyx_t_6, 17, ((PyObject *)__pyx_n_s__overlap_nsegments));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__overlap_nsegments));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__overlap_size));
  PyList_SET_ITEM(__pyx_t_6, 18, ((PyObject *)__pyx_n_s__overlap_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__overlap_size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__overlap_density));
  PyList_SET_ITEM(__pyx_t_6, 19, ((PyObject *)__pyx_n_s__overlap_density));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__overlap_density));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_142));
  PyList_SET_ITEM(__pyx_t_6, 20, ((PyObject *)__pyx_n_s_142));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_142));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_143));
  PyList_SET_ITEM(__pyx_t_6, 21, ((PyObject *)__pyx_n_s_143));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_143));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_144));
  PyList_SET_ITEM(__pyx_t_6, 22, ((PyObject *)__pyx_n_s_144));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_144));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_145));
  PyList_SET_ITEM(__pyx_t_6, 23, ((PyObject *)__pyx_n_s_145));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_145));
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_AnnotatorResultExtended->tp_dict, __pyx_n_s__headers, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  PyType_Modified(__pyx_ptype_9GatEngine_AnnotatorResultExtended);

  /* "GatEngine.pyx":1856
 *                   workspace,
 *                   reference = None,
 *                   pseudo_count = 1.0 ):             # <<<<<<<<<<<<<<
 * 
 *         AnnotatorResult.__init__( self, track, annotation, counter, observed, samples,
 */
  __pyx_t_6 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_29 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":1926
 * ############################################################
 * ############################################################
 * def getNormedPValue( value, r ):             # <<<<<<<<<<<<<<
 *     '''return pvalue assuming that samples are normal distributed.'''
 *     absval = abs(value - r.expected)
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_15getNormedPValue, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getNormedPValue, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1942
 * ############################################################
 * ############################################################
 * def getEmpiricalPValue( value, r ):             # <<<<<<<<<<<<<<
 *     return r.getEmpiricalPValue( value )
 * 
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_17getEmpiricalPValue, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getEmpiricalPValue, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1948
 * ############################################################
 * ############################################################
 * def updatePValues( annotator_results, method = "empirical" ):             # <<<<<<<<<<<<<<
 *     '''update pvalues.
 * 
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_19updatePValues, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__updatePValues, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1972
 * ############################################################
 * ############################################################
 * def getQValues( pvalues, method = "storey", **kwargs ):             # <<<<<<<<<<<<<<
 *     '''return a list of qvalues for a list of pvalues.'''
 * 
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_21getQValues, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getQValues, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1991
 * ############################################################
 * ############################################################
 * def updateQValues( annotator_results, method = "storey", **kwargs ):             # <<<<<<<<<<<<<<
 *     '''update qvalues in annotator results
 * 
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_23updateQValues, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__updateQValues, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2008
 * ## Workspace generators
 * ############################################################
 * class UnconditionalWorkspace:             # <<<<<<<<<<<<<<
 *     '''compute a conditional workspace.
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2013
 *     the default workspace is not conditional.'''
 * 
 *     is_conditional = False             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, segments, annotations, workspace):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__is_conditional, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2015
 *     is_conditional = False
 * 
 *     def __call__(self, segments, annotations, workspace):             # <<<<<<<<<<<<<<
 *         return segments, annotations, workspace
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_22UnconditionalWorkspace_1__call__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_157)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____call__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2018
 *         return segments, annotations, workspace
 * 
 *     def filter( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 *         '''restrict annotations and segments to workspace.
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_22UnconditionalWorkspace_3filter, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_159)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__filter, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2008
 * ## Workspace generators
 * ############################################################
 * class UnconditionalWorkspace:             # <<<<<<<<<<<<<<
 *     '''compute a conditional workspace.
 * 
 */
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_160)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_6), __pyx_n_s_161, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_161, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2040
 *         return temp_segments, temp_annotations, workspace
 * 
 * class ConditionalWorkspaceCooccurance( UnconditionalWorkspace):             # <<<<<<<<<<<<<<
 *     '''compute conditional workspace.
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2047
 *     '''
 * 
 *     is_conditional = True             # <<<<<<<<<<<<<<
 * 
 *     def __call__( self, segments, annotations, workspace ):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__is_conditional, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2049
 *     is_conditional = True
 * 
 *     def __call__( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 * 
 *         # restrict workspace to those segments that contain both annotations and segments
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_31ConditionalWorkspaceCooccurance_1__call__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_163)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____call__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2040
 *         return temp_segments, temp_annotations, workspace
 * 
 * class ConditionalWorkspaceCooccurance( UnconditionalWorkspace):             # <<<<<<<<<<<<<<
 *     '''compute conditional workspace.
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_161); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_164)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6), __pyx_n_s_165, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_165, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2058
 *         return self.filter( segments, annotations, temp_workspace )
 * 
 * class ConditionalWorkspaceCentered( UnconditionalWorkspace ):             # <<<<<<<<<<<<<<
 *     '''a workspace centered around segments/annotations.'''
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2061
 *     '''a workspace centered around segments/annotations.'''
 * 
 *     is_conditional = True             # <<<<<<<<<<<<<<
 * 
 *     def __init__( self, extension = None, expansion = None ):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__is_conditional, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2063
 *     is_conditional = True
 * 
 *     def __init__( self, extension = None, expansion = None ):             # <<<<<<<<<<<<<<
 *         self.extension = extension
 *         self.expansion = expansion
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_28ConditionalWorkspaceCentered_1__init__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_167)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, ((PyObject *)__pyx_k_tuple_168));
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2069
 *             raise ValueError( "need to specify either expansion or extension" )
 * 
 *     def __call__( self, segments, annotations, workspace ):             # <<<<<<<<<<<<<<
 * 
 *         # build workspace from annotations
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_28ConditionalWorkspaceCentered_3__call__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_170)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____call__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2058
 *         return self.filter( segments, annotations, temp_workspace )
 * 
 * class ConditionalWorkspaceCentered( UnconditionalWorkspace ):             # <<<<<<<<<<<<<<
 *     '''a workspace centered around segments/annotations.'''
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_161); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_171)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6), __pyx_n_s_172, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_172, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2084
 *         return self.filter( segments, annotations, temp_workspace )
 * 
 * class ConditionalWorkspaceAnnotationCentered( ConditionalWorkspaceCentered ):             # <<<<<<<<<<<<<<
 *     '''compute conditional workspace.
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2089
 *     workspace is derived from the locations of the annotations.
 *     '''
 *     def getCenter( self, segments, annotations):             # <<<<<<<<<<<<<<
 *         return annotations
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_38ConditionalWorkspaceAnnotationCentered_1getCenter, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_174)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__getCenter, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2084
 *         return self.filter( segments, annotations, temp_workspace )
 * 
 * class ConditionalWorkspaceAnnotationCentered( ConditionalWorkspaceCentered ):             # <<<<<<<<<<<<<<
 *     '''compute conditional workspace.
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_172); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_175)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6), __pyx_n_s_176, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_176, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2092
 *         return annotations
 * 
 * class ConditionalWorkspaceSegmentCentered( ConditionalWorkspaceCentered ):             # <<<<<<<<<<<<<<
 *     '''compute conditional workspace.
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2098
 *     '''
 *     # workspace needs to be computed on a per-segment basis
 *     is_conditional = False             # <<<<<<<<<<<<<<
 *     def getCenter( self, segments, annotations):
 *         return segments
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__is_conditional, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2099
 *     # workspace needs to be computed on a per-segment basis
 *     is_conditional = False
 *     def getCenter( self, segments, annotations):             # <<<<<<<<<<<<<<
 *         return segments
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_35ConditionalWorkspaceSegmentCentered_1getCenter, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_178)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__getCenter, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2092
 *         return annotations
 * 
 * class ConditionalWorkspaceSegmentCentered( ConditionalWorkspaceCentered ):             # <<<<<<<<<<<<<<
 *     '''compute conditional workspace.
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_172); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_179)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6), __pyx_n_s_180, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_180, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2107
 * ## compute counts
 * ############################################################
 * def _append( counts, x,y,z): counts[y].append(z)             # <<<<<<<<<<<<<<
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )
 * def _defdictfloat(): return collections.defaultdict(float)
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_25_append, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___append, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2108
 * ############################################################
 * def _append( counts, x,y,z): counts[y].append(z)
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )             # <<<<<<<<<<<<<<
 * def _defdictfloat(): return collections.defaultdict(float)
 * 
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_27_set, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___set, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2109
 * def _append( counts, x,y,z): counts[y].append(z)
 * def _set( counts, x,y,z) : counts[x].__setitem__( y, z )
 * def _defdictfloat(): return collections.defaultdict(float)             # <<<<<<<<<<<<<<
 * 
 * def computeCounts( counter,
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_29_defdictfloat, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___defdictfloat, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2117
 *                    workspace,
 *                    workspace_generator,
 *                    append = False):             # <<<<<<<<<<<<<<
 *     '''collect counts from *counter* between all combinations of *segments* and *annotations*.
 * 
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_41 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":2111
 * def _defdictfloat(): return collections.defaultdict(float)
 * 
 * def computeCounts( counter,             # <<<<<<<<<<<<<<
 *                    aggregator,
 *                    segments,
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_31computeCounts, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__computeCounts, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2314
 *            return self.track
 * 
 * class Track(object):             # <<<<<<<<<<<<<<
 *     '''bed track information.'''
 *     def __init__(self, line ):
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2316
 * class Track(object):
 *     '''bed track information.'''
 *     def __init__(self, line ):             # <<<<<<<<<<<<<<
 *         r= re.compile('([^\s=]+) *= *("[^"]*"|[^ ]*)')
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_5Track_1__init__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_189)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2327
 * 
 *         self._line = line[:-1]
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self._line
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_5Track_3__str__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_191)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____str__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2330
 *         return self._line
 * 
 *     def __getitem__(self, key): return self._d[key]             # <<<<<<<<<<<<<<
 *     def __setitem__(self, key,val): self._d[key] = val
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_5Track_5__getitem__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_193)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____getitem__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2331
 * 
 *     def __getitem__(self, key): return self._d[key]
 *     def __setitem__(self, key,val): self._d[key] = val             # <<<<<<<<<<<<<<
 * 
 * class tsv_iterator:
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_5Track_7__setitem__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_195)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____setitem__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "GatEngine.pyx":2314
 *            return self.track
 * 
 * class Track(object):             # <<<<<<<<<<<<<<
 *     '''bed track information.'''
 *     def __init__(self, line ):
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_196)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_6), __pyx_n_s__Track, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Track, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2333
 *     def __setitem__(self, key,val): self._d[key] = val
 * 
 * class tsv_iterator:             # <<<<<<<<<<<<<<
 *     '''iterate over ``infile``.
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2338
 *     Permits the use of file-like objects for example from the gzip module.
 *     '''
 *     def __init__(self, infile ):             # <<<<<<<<<<<<<<
 * 
 *         self.infile = infile
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12tsv_iterator_1__init__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_198)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2342
 *         self.infile = infile
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12tsv_iterator_3__iter__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_200)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____iter__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2345
 *         return self
 * 
 *     def preparse( self, line ):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12tsv_iterator_5preparse, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_202)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__preparse, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2348
 *         return True
 * 
 *     def create( self):             # <<<<<<<<<<<<<<
 *         return TupleProxy()
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12tsv_iterator_7create, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_204)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__create, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2351
 *         return TupleProxy()
 * 
 *     def next(self):             # <<<<<<<<<<<<<<
 * 
 *         cdef char * b
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12tsv_iterator_9next, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_206)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__next, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2333
 *     def __setitem__(self, key,val): self._d[key] = val
 * 
 * class tsv_iterator:             # <<<<<<<<<<<<<<
 *     '''iterate over ``infile``.
 * 
 */
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_207)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_6), __pyx_n_s__tsv_iterator, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tsv_iterator, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2393
 *         raise StopIteration
 * 
 * class bed_iterator(tsv_iterator):             # <<<<<<<<<<<<<<
 *     '''iterate over ``infile``.
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "GatEngine.pyx":2398
 *     Permits the use of file-like objects for example from the gzip module.
 *     '''
 *     def __init__(self, infile ):             # <<<<<<<<<<<<<<
 *         tsv_iterator.__init__(self, infile )
 *         self.track = None
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12bed_iterator_1__init__, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_209)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2402
 *         self.track = None
 * 
 *     def preparse(self, line ):             # <<<<<<<<<<<<<<
 *         if line.startswith("track"):
 *             self.track = Track( line )
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12bed_iterator_3preparse, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_211)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__preparse, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2408
 *         return True
 * 
 *     def create( self ):             # <<<<<<<<<<<<<<
 *         return BedProxy( self.track )
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9GatEngine_12bed_iterator_5create, 0, NULL, __pyx_n_s__GatEngine, ((PyObject *)__pyx_k_codeobj_213)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetItem(__pyx_t_6, __pyx_n_s__create, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "GatEngine.pyx":2393
 *         raise StopIteration
 * 
 * class bed_iterator(tsv_iterator):             # <<<<<<<<<<<<<<
 *     '''iterate over ``infile``.
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tsv_iterator); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_6), "__doc__", ((PyObject *)__pyx_kp_s_207)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_6), __pyx_n_s__bed_iterator, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__bed_iterator, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2411
 *         return BedProxy( self.track )
 * 
 * def _genie():             # <<<<<<<<<<<<<<
 *     return IntervalCollection(SegmentList)
 * 
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_33_genie, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___genie, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2414
 *     return IntervalCollection(SegmentList)
 * 
 * def readFromBed( filenames, allow_multiple = False ):             # <<<<<<<<<<<<<<
 *     '''read Segment Lists from one or more bed files.
 * 
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_52 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_35readFromBed, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__readFromBed, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2741
 *                 del self.intervals[contig]
 * 
 *     def toIsochores( self, isochores, truncate = False ):             # <<<<<<<<<<<<<<
 *         '''split per-contig segmentlists into per-isochore segmentlist.
 * 
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_73 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":2780
 *         self.intervals = new
 * 
 * def buildIntervalDictionary( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_37buildIntervalDictionary, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_70, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":2816
 *                 yield segmentlist
 * 
 *     def load( self, filenames, split_tracks = False ):             # <<<<<<<<<<<<<<
 *         '''load segments from filenames and pre-process them.'''
 *         self.intervals = readFromBed( filenames, split_tracks )
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_79 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":2877
 * 
 * 
 *     def merge( self, delete = False ):             # <<<<<<<<<<<<<<
 *         '''merge all tracks into a single segment list
 *         creating a new track called 'merged'.
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_88 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":2965
 *                 del self.intervals[track]
 * 
 *     def toIsochores( self, isochores, truncate = False ):             # <<<<<<<<<<<<<<
 *         '''split per-contig segmentlists into per-isochore segmentlist.
 * 
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_89 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "GatEngine.pyx":2990
 * 
 *     @property
 *     def tracks(self): return self.intervals.keys()             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self): return len(self.intervals)
 */
  __pyx_t_6 = __Pyx_GetName((PyObject *)__pyx_ptype_9GatEngine_IntervalCollection, __pyx_n_s__tracks); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9GatEngine_IntervalCollection->tp_dict, __pyx_n_s__tracks, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  PyType_Modified(__pyx_ptype_9GatEngine_IntervalCollection);

  /* "GatEngine.pyx":3029
 *                          "%f" % (float(overlap) / length)) ) + "\n" )
 * 
 * def buildIntervalCollection( *args ):             # <<<<<<<<<<<<<<
 *     '''unpickling - return a rebuilt SamplerShift object.'''
 *     return IntervalCollection( unreduce = args )
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_9GatEngine_39buildIntervalCollection, NULL, __pyx_n_s__GatEngine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_78, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "GatEngine.pyx":1
 * # cython: embedsignature=True             # <<<<<<<<<<<<<<
 * # cython: profile=False
 * 
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "numpy.pxd":975
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__pyx_m) {
    __Pyx_AddTraceback("init GatEngine", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init GatEngine");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    #if PY_VERSION_HEX < 0x02050000
    if (PyClass_Check(type)) {
    #else
    if (PyType_Check(type)) {
    #endif
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *args;
        if (!value)
            args = PyTuple_New(0);
        else if (PyTuple_Check(value)) {
            Py_INCREF(value);
            args = value;
        }
        else
            args = PyTuple_Pack(1, value);
        if (!args)
            goto bad;
        owned_instance = PyEval_CallObject(type, args);
        Py_DECREF(args);
        if (!owned_instance)
            goto bad;
        value = owned_instance;
        if (!PyExceptionInstance_Check(value)) {
            PyErr_Format(PyExc_TypeError,
                         "calling %R should have returned an instance of "
                         "BaseException, not %R",
                         type, Py_TYPE(value));
            goto bad;
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause && cause != Py_None) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  unsigned int n = 1;
  return *(unsigned char*)(&n) != 0;
}
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1) /* First char was not a digit */
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count; /* Consume from buffer string */
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break; /* breaks both loops as ctx->enc_count == 0 */
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue; /* empty struct */
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        if (isspace(*ts))
            continue;
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
                return ts;
      case ' ':
      case 10:
      case 13:
        ++ts;
        break;
      case '<':
        if (!__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T': /* substruct */
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0; /* Erase processed last struct element */
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}': /* end of substruct; either repeat or move on */
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0; /* Erase processed last struct element */
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }        /* fall through */
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 's': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
        } else {
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_count = ctx->new_count;
          ctx->enc_packmode = ctx->new_packmode;
          ctx->enc_type = *ts;
          ctx->is_complex = got_Z;
        }
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  if (obj == Py_None || obj == NULL) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CPYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t q = a / b;
    Py_ssize_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if CYTHON_COMPILING_IN_PYPY
    float_value = PyNumber_Float(obj);
#else
    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
        return PyFloat_AsDouble(obj);
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
#endif
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (DECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                             int is_tuple, int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
        iternextfunc iternext;
        iter = PyObject_GetIter(tuple);
        if (unlikely(!iter)) goto bad;
        if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
        iternext = Py_TYPE(iter)->tp_iternext;
        value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
        value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
        if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
        Py_DECREF(iter);
    } else {
        if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
            __Pyx_UnpackTupleError(tuple, 2);
            goto bad;
        }
#if CYTHON_COMPILING_IN_PYPY
        value1 = PySequence_ITEM(tuple, 0);
        if (unlikely(!value1)) goto bad;
        value2 = PySequence_ITEM(tuple, 1);
        if (unlikely(!value2)) goto bad;
#else
        value1 = PyTuple_GET_ITEM(tuple, 0);
        value2 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(value1);
        Py_INCREF(value2);
#endif
        if (decref_tuple) { Py_DECREF(tuple); }
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
#if !CYTHON_COMPILING_IN_PYPY
    if (is_dict) {
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
    }
#endif
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = PyObject_CallMethodObjArgs(iterable, method_name, NULL);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* iter_obj, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_traverse != current_tp_traverse)
        type = type->tp_base;
    while (type && type->tp_traverse == current_tp_traverse)
        type = type->tp_base;
    if (type && type->tp_traverse)
        return type->tp_traverse(obj, v, a);
    return 0;
}

static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_clear != current_tp_clear)
        type = type->tp_base;
    while (type && type->tp_clear == current_tp_clear)
        type = type->tp_base;
    if (type && type->tp_clear)
        type->tp_clear(obj);
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    CYTHON_UNUSED PyObject *getbuffer_cobj;
  #if PY_VERSION_HEX >= 0x02060000
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
  #endif
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
  #if PY_VERSION_HEX < 0x02060000
    if (obj->ob_type->tp_dict &&
        (getbuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict,
                                             "__pyx_getbuffer"))) {
        getbufferproc func;
      #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0)
        func = (getbufferproc) PyCapsule_GetPointer(getbuffer_cobj, "getbuffer(obj, view, flags)");
      #else
        func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
      #endif
        Py_DECREF(getbuffer_cobj);
        if (!func)
            goto fail;
        return func(obj, view, flags);
    } else {
        PyErr_Clear();
    }
  #endif
    PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
#if PY_VERSION_HEX < 0x02060000
fail:
#endif
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    CYTHON_UNUSED PyObject *releasebuffer_cobj;
    if (!obj) return;
  #if PY_VERSION_HEX >= 0x02060000
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
  #endif
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
  #if PY_VERSION_HEX < 0x02060000
    if (obj->ob_type->tp_dict &&
        (releasebuffer_cobj = PyMapping_GetItemString(obj->ob_type->tp_dict,
                                                      "__pyx_releasebuffer"))) {
        releasebufferproc func;
      #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 0)
        func = (releasebufferproc) PyCapsule_GetPointer(releasebuffer_cobj, "releasebuffer(obj, view)");
      #else
        func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
      #endif
        Py_DECREF(releasebuffer_cobj);
        if (!func)
            goto fail;
        func(obj, view);
        return;
    } else {
        PyErr_Clear();
    }
  #endif
    goto nofail;
#if PY_VERSION_HEX < 0x02060000
fail:
#endif
    PyErr_WriteUnraisable(obj);
nofail:
    Py_DECREF(obj);
    view->obj = NULL;
}
#endif /*  PY_MAJOR_VERSION < 3 */


    static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                /* try package relative import first */
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, (char *)"__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;
    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}

static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (op->func_doc == NULL && op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
        op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
        op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
    }
    if (op->func_doc == 0) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL)
        op->func_doc = Py_None; /* Mark as deleted */
    else
        op->func_doc = value;
    Py_INCREF(op->func_doc);
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (op->func_name == NULL) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (value == NULL || !PyUnicode_Check(value)) {
#else
    if (value == NULL || !PyString_Check(value)) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (op->func_dict == NULL) {
        op->func_dict = PyDict_New();
        if (op->func_dict == NULL)
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (value == NULL) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    PyObject* dict = PyModule_GetDict(__pyx_m);
    Py_XINCREF(dict);
    return dict;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
{
    if (op->defaults_tuple) {
        Py_INCREF(op->defaults_tuple);
        return op->defaults_tuple;
    }
    if (op->defaults_getter) {
        PyObject *res = op->defaults_getter((PyObject *) op);
        if (res) {
            Py_INCREF(res);
            op->defaults_tuple = res;
        }
        return res;
    }
    Py_INCREF(Py_None);
    return Py_None;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
    {0, 0, 0, 0, 0}
};
#ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
#define PY_WRITE_RESTRICTED WRITE_RESTRICTED
#endif
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
                                      PyObject *closure, PyObject *module, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    op->func_weakreflist = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_getter = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyMem_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (m->func_weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return PyMethod_New(func,
                            type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
    PyObject *func_name = __Pyx_CyFunction_get_name(op);
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                func_name, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(func_name), (void *)op);
#endif
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    Py_ssize_t size;
    switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
    case METH_VARARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0)
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 0)
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%zd given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 1)
                return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%zd given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
    sizeof(__pyx_CyFunctionObject),   /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    (reprfunc) __Pyx_CyFunction_repr,   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    __Pyx_CyFunction_Call,              /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_CyFunction_traverse,   /*tp_traverse*/
    (inquiry) __Pyx_CyFunction_clear,   /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    0,                                  /*tp_iternext*/
    __pyx_CyFunction_methods,           /*tp_methods*/
    __pyx_CyFunction_members,           /*tp_members*/
    __pyx_CyFunction_getsets,           /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    __Pyx_CyFunction_descr_get,         /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
    0,                                  /*tp_del*/
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
};
static int __Pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
        return -1;
    __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyMem_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, sizeof(size));
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}

static PyObject* __pyx_convert__to_py___pyx_t_14GatSegmentList_Segment(struct __pyx_t_14GatSegmentList_Segment s) {
        PyObject* res;
        PyObject* member;
        res = PyDict_New(); if (res == NULL) return NULL;
        member = PyLong_FromUnsignedLong(s.start); if (member == NULL) goto bad;
        if (PyDict_SetItem(res, __pyx_n_s__start, member) < 0) goto bad;
        Py_DECREF(member);
        member = PyLong_FromUnsignedLong(s.end); if (member == NULL) goto bad;
        if (PyDict_SetItem(res, __pyx_n_s__end, member) < 0) goto bad;
        Py_DECREF(member);
        return res;
        bad:
        Py_XDECREF(member);
        Py_DECREF(res);
        return NULL;
      }
      static CYTHON_INLINE off_t __Pyx_PyInt_from_py_off_t(PyObject* x) {
    const off_t neg_one = (off_t)-1, const_zero = (off_t)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(off_t) == sizeof(char)) {
        if (is_unsigned)
            return (off_t)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (off_t)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(off_t) == sizeof(short)) {
        if (is_unsigned)
            return (off_t)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (off_t)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(off_t) == sizeof(int)) {
        if (is_unsigned)
            return (off_t)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (off_t)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(off_t) == sizeof(long)) {
        if (is_unsigned)
            return (off_t)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (off_t)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(off_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (off_t)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (off_t)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
        PyErr_SetString(PyExc_RuntimeError,
                        "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
        #else
        off_t val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        #endif
        return (off_t)-1;
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_off_t(off_t val) {
    const off_t neg_one = (off_t)-1, const_zero = (off_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(off_t) == sizeof(char))  ||
        (sizeof(off_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(off_t) == sizeof(int)) ||
               (sizeof(off_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(off_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(off_t),
                                     little, !is_unsigned);
    }
}

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        float denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(a, a);
                    case 3:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, a);
                    case 4:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_absf(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        double denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(a, a);
                    case 3:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, a);
                    case 4:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_abs(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

static PyObject *__Pyx_Generator_Next(PyObject *self);
static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Generator_Close(PyObject *self);
static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args);
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (unlikely(et != PyExc_StopIteration) &&
            unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) {
            if (!ev) {
                Py_INCREF(Py_None);
                ev = Py_None;
            }
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = ev;
            return 0;
        }
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = PyObject_GetAttrString(ev, "args");
        Py_DECREF(ev);
        if (likely(args)) {
            value = PyObject_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
#endif
static CYTHON_INLINE
void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) {
    PyObject *exc_type = self->exc_type;
    PyObject *exc_value = self->exc_value;
    PyObject *exc_traceback = self->exc_traceback;
    self->exc_type = NULL;
    self->exc_value = NULL;
    self->exc_traceback = NULL;
    Py_XDECREF(exc_type);
    Py_XDECREF(exc_value);
    Py_XDECREF(exc_traceback);
}
static CYTHON_INLINE
int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) {
    if (unlikely(gen->is_running)) {
        PyErr_SetString(PyExc_ValueError,
                        "generator already executing");
        return 1;
    }
    return 0;
}
static CYTHON_INLINE
PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            PyErr_SetString(PyExc_TypeError,
                            "can't send non-None value to a "
                            "just-started generator");
            return NULL;
        }
    }
    if (unlikely(self->resume_label == -1)) {
        PyErr_SetNone(PyExc_StopIteration);
        return NULL;
    }
    if (value) {
#if CYTHON_COMPILING_IN_PYPY
#else
        /* Generators always return to their most recent caller, not
         * necessarily their creator. */
        if (self->exc_traceback) {
            PyThreadState *tstate = PyThreadState_GET();
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Generator_ExceptionClear(self);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, value);
    self->is_running = 0;
    if (retval) {
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
#if CYTHON_COMPILING_IN_PYPY
#else
        /* Don't keep the reference to f_back any longer than necessary.  It
         * may keep a chain of frames alive or it could create a reference
         * cycle. */
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_CLEAR(f->f_back);
        }
#endif
    } else {
        __Pyx_Generator_ExceptionClear(self);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Generator_Undelegate(gen);
    __Pyx_PyGen_FetchStopIterationValue(&val);
    ret = __Pyx_Generator_SendEx(gen, val);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Generator_FinishDelegation(gen);
    }
    return __Pyx_Generator_SendEx(gen, Py_None);
}
static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Send(yf, value);
        } else {
            if (value == Py_None)
                ret = PyIter_Next(yf);
            else
                ret = PyObject_CallMethod(yf, (char*)"send", (char*)"O", value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Generator_FinishDelegation(gen);
    }
    return __Pyx_Generator_SendEx(gen, value);
}
static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Generator_Close(yf);
        if (!retval)
            return -1;
    } else {
        PyObject *meth;
        gen->is_running = 1;
        meth = PyObject_GetAttrString(yf, "close");
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Close(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Generator_CloseIter(gen, yf);
        __Pyx_Generator_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
#if PY_VERSION_HEX < 0x02050000
        PyErr_SetNone(PyExc_StopIteration);
#else
        PyErr_SetNone(PyExc_GeneratorExit);
#endif
    retval = __Pyx_Generator_SendEx(gen, NULL);
    if (retval) {
        Py_DECREF(retval);
        PyErr_SetString(PyExc_RuntimeError,
                        "generator ignored GeneratorExit");
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (!raised_exception
        || raised_exception == PyExc_StopIteration
#if PY_VERSION_HEX >= 0x02050000
        || raised_exception == PyExc_GeneratorExit
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
#endif
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
    {
        if (raised_exception) PyErr_Clear();      /* ignore these errors */
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject *typ;
    PyObject *tb = NULL;
    PyObject *val = NULL;
    PyObject *yf = gen->yieldfrom;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
#if PY_VERSION_HEX >= 0x02050000
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Generator_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Generator_Undelegate(gen);
            if (err < 0)
                return __Pyx_Generator_SendEx(gen, NULL);
            goto throw_here;
        }
#endif
        gen->is_running = 1;
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Throw(yf, args);
        } else {
            PyObject *meth = PyObject_GetAttrString(yf, "throw");
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Generator_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            ret = PyObject_CallObject(meth, args);
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Generator_FinishDelegation(gen);
        }
        return ret;
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Generator_SendEx(gen, NULL);
}
static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    Py_VISIT(gen->exc_type);
    Py_VISIT(gen->exc_value);
    Py_VISIT(gen->exc_traceback);
    return 0;
}
static int __Pyx_Generator_clear(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    Py_CLEAR(gen->exc_type);
    Py_CLEAR(gen->exc_value);
    Py_CLEAR(gen->exc_traceback);
    return 0;
}
static void __Pyx_Generator_dealloc(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    PyObject_GC_Track(self);
    if (gen->resume_label > 0) {
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
            return;                     /* resurrected.  :( */
    }
    PyObject_GC_UnTrack(self);
    __Pyx_Generator_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Generator_del(PyObject *self) {
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    if (gen->resume_label <= 0)
        return ;
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
    res = __Pyx_Generator_Close(self);
    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
    /* Undo the temporary resurrection; can't use DECREF here, it would
     * cause a recursive call.
     */
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0)
        return; /* this is the normal path out */
    /* close() resurrected it!  Make it look like the original Py_DECREF
     * never happened.
     */
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_FOR_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
     * we need to undo that. */
    _Py_DEC_REFTOTAL;
#endif
    /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
     * chain, so no more to do there.
     * If COUNT_ALLOCS, the original decref bumped tp_frees, and
     * _Py_NewReference bumped tp_allocs:  both of those need to be
     * undone.
     */
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
}
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running",
#if PY_VERSION_HEX >= 0x02060000
     T_BOOL,
#else
     T_BYTE,
#endif
     offsetof(__pyx_GeneratorObject, is_running),
     READONLY,
     NULL},
    {0, 0, 0, 0, 0}
};
static PyMethodDef __pyx_Generator_methods[] = {
    {__Pyx_NAMESTR("send"), (PyCFunction) __Pyx_Generator_Send, METH_O, 0},
    {__Pyx_NAMESTR("throw"), (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0},
    {__Pyx_NAMESTR("close"), (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
    {0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("generator"),         /*tp_name*/
    sizeof(__pyx_GeneratorObject),      /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_Generator_dealloc,/*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    0,                                   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    0,                                  /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_Generator_traverse,   /*tp_traverse*/
    0,                                  /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_GeneratorObject, gi_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/
    __pyx_Generator_methods,            /*tp_methods*/
    __pyx_Generator_memberlist,         /*tp_members*/
    0,                                  /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    0,                                  /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    0,                                  /*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
    __Pyx_Generator_del,                /*tp_del*/
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
};
static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
                                                  PyObject *closure) {
    __pyx_GeneratorObject *gen =
        PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type);
    if (gen == NULL)
        return NULL;
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->exc_type = NULL;
    gen->exc_value = NULL;
    gen->exc_traceback = NULL;
    gen->gi_weakreflist = NULL;
    PyObject_GC_Track(gen);
    return gen;
}
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    if (PyType_Ready(&__pyx_GeneratorType_type)) {
        return -1;
    }
    __pyx_GeneratorType = &__pyx_GeneratorType_type;
    return 0;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}


/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
